client+server: add quicktime video support
Merge branch 'skybldev-upstream'
This commit is contained in:
commit
648121d7c3
6 changed files with 18 additions and 1 deletions
|
@ -42,6 +42,7 @@
|
||||||
'image/heic': 'HEIC',
|
'image/heic': 'HEIC',
|
||||||
'video/webm': 'WEBM',
|
'video/webm': 'WEBM',
|
||||||
'video/mp4': 'MPEG-4',
|
'video/mp4': 'MPEG-4',
|
||||||
|
'video/quicktime': 'MOV',
|
||||||
'application/x-shockwave-flash': 'SWF',
|
'application/x-shockwave-flash': 'SWF',
|
||||||
}[ctx.post.mimeType] +
|
}[ctx.post.mimeType] +
|
||||||
' (' +
|
' (' +
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
'image/heic': 'HEIC',
|
'image/heic': 'HEIC',
|
||||||
'video/webm': 'WEBM',
|
'video/webm': 'WEBM',
|
||||||
'video/mp4': 'MPEG-4',
|
'video/mp4': 'MPEG-4',
|
||||||
|
'video/quicktime': 'MOV',
|
||||||
'application/x-shockwave-flash': 'SWF',
|
'application/x-shockwave-flash': 'SWF',
|
||||||
}[ctx.post.mimeType] %>
|
}[ctx.post.mimeType] %>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -22,6 +22,7 @@ function _mimeTypeToPostType(mimeType) {
|
||||||
"image/heic": "image",
|
"image/heic": "image",
|
||||||
"video/mp4": "video",
|
"video/mp4": "video",
|
||||||
"video/webm": "video",
|
"video/webm": "video",
|
||||||
|
"video/quicktime": "video",
|
||||||
}[mimeType] || "unknown"
|
}[mimeType] || "unknown"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -120,6 +121,7 @@ class Url extends Uploadable {
|
||||||
heif: "image/heif",
|
heif: "image/heif",
|
||||||
heic: "image/heic",
|
heic: "image/heic",
|
||||||
mp4: "video/mp4",
|
mp4: "video/mp4",
|
||||||
|
mov: "video/quicktime",
|
||||||
webm: "video/webm",
|
webm: "video/webm",
|
||||||
};
|
};
|
||||||
for (let extension of Object.keys(mime)) {
|
for (let extension of Object.keys(mime)) {
|
||||||
|
|
|
@ -39,6 +39,9 @@ def get_mime_type(content: bytes) -> str:
|
||||||
if content[4:12] in (b"ftypisom", b"ftypiso5", b"ftypiso6", b"ftypmp42", b"ftypM4V "):
|
if content[4:12] in (b"ftypisom", b"ftypiso5", b"ftypiso6", b"ftypmp42", b"ftypM4V "):
|
||||||
return "video/mp4"
|
return "video/mp4"
|
||||||
|
|
||||||
|
if content[4:12] == b"ftypqt ":
|
||||||
|
return "video/quicktime"
|
||||||
|
|
||||||
return "application/octet-stream"
|
return "application/octet-stream"
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,6 +57,7 @@ def get_extension(mime_type: str) -> Optional[str]:
|
||||||
"image/heif": "heif",
|
"image/heif": "heif",
|
||||||
"image/heic": "heic",
|
"image/heic": "heic",
|
||||||
"video/mp4": "mp4",
|
"video/mp4": "mp4",
|
||||||
|
"video/quicktime": "mov",
|
||||||
"video/webm": "webm",
|
"video/webm": "webm",
|
||||||
"application/octet-stream": "dat",
|
"application/octet-stream": "dat",
|
||||||
}
|
}
|
||||||
|
@ -65,7 +69,12 @@ def is_flash(mime_type: str) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def is_video(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:
|
def is_image(mime_type: str) -> bool:
|
||||||
|
|
BIN
server/szurubooru/tests/assets/mov.mov
Normal file
BIN
server/szurubooru/tests/assets/mov.mov
Normal file
Binary file not shown.
|
@ -7,6 +7,7 @@ from szurubooru.func import mime
|
||||||
"input_path,expected_mime_type",
|
"input_path,expected_mime_type",
|
||||||
[
|
[
|
||||||
("mp4.mp4", "video/mp4"),
|
("mp4.mp4", "video/mp4"),
|
||||||
|
("mov.mov", "video/quicktime"),
|
||||||
("webm.webm", "video/webm"),
|
("webm.webm", "video/webm"),
|
||||||
("flash.swf", "application/x-shockwave-flash"),
|
("flash.swf", "application/x-shockwave-flash"),
|
||||||
("png.png", "image/png"),
|
("png.png", "image/png"),
|
||||||
|
@ -35,6 +36,7 @@ def test_get_mime_type_for_empty_file():
|
||||||
[
|
[
|
||||||
("video/mp4", "mp4"),
|
("video/mp4", "mp4"),
|
||||||
("video/webm", "webm"),
|
("video/webm", "webm"),
|
||||||
|
("video/quicktime", "mov"),
|
||||||
("application/x-shockwave-flash", "swf"),
|
("application/x-shockwave-flash", "swf"),
|
||||||
("image/png", "png"),
|
("image/png", "png"),
|
||||||
("image/jpeg", "jpg"),
|
("image/jpeg", "jpg"),
|
||||||
|
@ -70,6 +72,8 @@ def test_is_flash(input_mime_type, expected_state):
|
||||||
("VIDEO/WEBM", True),
|
("VIDEO/WEBM", True),
|
||||||
("video/mp4", True),
|
("video/mp4", True),
|
||||||
("VIDEO/MP4", True),
|
("VIDEO/MP4", True),
|
||||||
|
("video/quicktime", True),
|
||||||
|
("VIDEO/QUICKTIME", True),
|
||||||
("video/anything_else", False),
|
("video/anything_else", False),
|
||||||
("application/ogg", True),
|
("application/ogg", True),
|
||||||
("not a video", False),
|
("not a video", False),
|
||||||
|
|
Loading…
Reference in a new issue