summaryrefslogtreecommitdiff
path: root/server/szurubooru/func/mime.py
diff options
context:
space:
mode:
authorHunternif <hunternif@gmail.com>2025-02-15 18:12:57 +0000
committerHunternif <hunternif@gmail.com>2025-02-15 18:12:57 +0000
commit6a5300502df8b4de9c8f269b444cd309f02b28ad (patch)
tree0cf2ba56bce802c94ad324f9eda7a31d37a42e2e /server/szurubooru/func/mime.py
parent34e7c883808738871aed371948a3c9896a95905c (diff)
parent376f687c386f65522b2f65e98b998b21af26ee29 (diff)
Merge branch 'master' into hunternif
Diffstat (limited to 'server/szurubooru/func/mime.py')
-rw-r--r--server/szurubooru/func/mime.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/server/szurubooru/func/mime.py b/server/szurubooru/func/mime.py
index 93c096b..8fae567 100644
--- a/server/szurubooru/func/mime.py
+++ b/server/szurubooru/func/mime.py
@@ -36,9 +36,12 @@ def get_mime_type(content: bytes) -> str:
if content[0:4] == b"\x1A\x45\xDF\xA3":
return "video/webm"
- if content[4:12] in (b"ftypisom", b"ftypiso5", b"ftypmp42", b"ftypM4V "):
+ if content[4:12] in (b"ftypisom", b"ftypiso5", b"ftypiso6", b"ftypmp42", b"ftypM4V "):
return "video/mp4"
+ if content[4:12] == b"ftypqt ":
+ return "video/quicktime"
+
return "application/octet-stream"
@@ -54,6 +57,7 @@ def get_extension(mime_type: str) -> Optional[str]:
"image/heif": "heif",
"image/heic": "heic",
"video/mp4": "mp4",
+ "video/quicktime": "mov",
"video/webm": "webm",
"application/octet-stream": "dat",
}
@@ -65,7 +69,12 @@ def is_flash(mime_type: str) -> bool:
def is_video(mime_type: str) -> bool:
- return mime_type.lower() in ("application/ogg", "video/mp4", "video/webm")
+ return mime_type.lower() in (
+ "application/ogg",
+ "video/mp4",
+ "video/quicktime",
+ "video/webm",
+ )
def is_image(mime_type: str) -> bool:
@@ -88,6 +97,7 @@ def is_animated_gif(content: bytes) -> bool:
and len(re.findall(pattern, content)) > 1
)
+
def is_heif(mime_type: str) -> bool:
return mime_type.lower() in (
"image/heif",