返回提交历史
Modified
g4f/image/__init__.py
+7
-0
XFEstudio/gpt4free
fix(image): support additional video formats in upload
- Add mov, avi, ogv, mpg, mpeg to EXTENSIONS_MAP - Fix detect_file_type() to return video/mp4 for non-HEIC/AVIF ftyp brands MP4 files with video brands (dash, iso6, avc1, etc.) were failing to upload because detect_file_type() only recognized HEIC/AVIF brands from the ftyp atom, falling through to 'Unknown or unsupported file type'. Fixes video upload errors in Qwen and other providers that use detect_file_type() to validate media files.
d22c919c
代码差异
1 个文件
+7
-0
@@ -46,6 +46,11 @@ EXTENSIONS_MAP: dict[str, str] = {
46
46
"mkv": "video/x-matroska",
47
47
"webm": "video/webm",
48
48
"mp4": "video/mp4",
49
"mov": "video/quicktime",
50
"avi": "video/x-msvideo",
51
"ogv": "video/ogg",
52
"mpg": "video/mpeg",
53
"mpeg": "video/mpeg",
49
54
}
50
55
51
56
MEDIA_TYPE_MAP: dict[str, str] = {value: key for key, value in EXTENSIONS_MAP.items()}
@@ -284,6 +289,8 @@ def detect_file_type(binary_data: bytes) -> tuple[str, str] | None:
284
289
return ".heic", "image/heif"
285
290
elif brand in [b"avif"]:
286
291
return ".avif", "image/avif"
292
else:
293
return ".mp4", "video/mp4"
287
294
elif binary_data.lstrip().startswith((b"<?xml", b"<svg")):
288
295
return ".svg", "image/svg+xml"
289
296