dragonxd1 commited on
Commit
14ed35b
·
1 Parent(s): 596c52f

Detect video docs by file extension

Browse files
Files changed (1) hide show
  1. backend/main.py +16 -2
backend/main.py CHANGED
@@ -226,8 +226,22 @@ def fmt_dur(seconds: int | None) -> str:
226
  def extract_vid(msg):
227
  if msg.video:
228
  return msg.video
229
- if msg.document and msg.document.mime_type and msg.document.mime_type.startswith("video"):
230
- return msg.document
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  return None
232
 
233
 
 
226
  def extract_vid(msg):
227
  if msg.video:
228
  return msg.video
229
+ if msg.document:
230
+ mime = getattr(msg.document, "mime_type", None) or ""
231
+ if mime.startswith("video"):
232
+ return msg.document
233
+ file_name = (getattr(msg.document, "file_name", "") or "").lower()
234
+ if file_name.endswith((
235
+ ".mp4",
236
+ ".mkv",
237
+ ".mov",
238
+ ".avi",
239
+ ".webm",
240
+ ".m4v",
241
+ ".ts",
242
+ ".m2ts",
243
+ )):
244
+ return msg.document
245
  return None
246
 
247