This commit is contained in:
uonr 2023-02-01 20:06:26 -07:00 committed by GitHub
commit 8a6d72ea49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 4 deletions

View file

@ -26,6 +26,7 @@ const external_js = [
'marked',
'mousetrap',
'nprogress',
'flv.js',
'superagent',
'underscore',
];

View file

@ -1,5 +1,6 @@
"use strict";
const flvjs = require("flv.js");
const iosCorrectedInnerHeight = require("ios-inner-height");
const router = require("../router.js");
const views = require("../util/views.js");
@ -49,6 +50,16 @@ class PostMainView {
postContainerNode.querySelector(".post-overlay"),
ctx.post
);
if (ctx.post.mimeType === "video/x-flv" && flvjs.isSupported()) {
const video = document.querySelector(".post-content video");
const src = video.querySelector("source").src
const player = flvjs.createPlayer({
type: 'flv',
url: src,
});
player.attachMediaElement(video);
player.load();
}
if (ctx.post.type === "video" || ctx.post.type === "flash") {
this._postContentControl.disableOverlay();

View file

@ -163,7 +163,7 @@ class PostUploadView extends events.EventTarget {
this._contentInputNode,
{
extraText:
"Allowed extensions: .jpg, .png, .gif, .webm, .mp4, .swf, .avif, .heif, .heic",
"Allowed extensions: .jpg, .png, .gif, .webm, .mp4, .swf, .avif, .heif, .heic, .flv",
allowUrls: true,
allowMultiple: true,
lock: false,

View file

@ -7,6 +7,7 @@
},
"dependencies": {
"dompurify": "^2.0.17",
"flv.js": "^1.6.2",
"font-awesome": "^4.7.0",
"ios-inner-height": "^1.0.3",
"js-cookie": "^2.2.0",

View file

@ -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 "):
return "video/mp4"
if content[0:3] == b"FLV":
return "video/x-flv"
return "application/octet-stream"
@ -55,17 +58,16 @@ def get_extension(mime_type: str) -> Optional[str]:
"image/heic": "heic",
"video/mp4": "mp4",
"video/webm": "webm",
"video/x-flv": "flv",
"application/octet-stream": "dat",
}
return extension_map.get((mime_type or "").strip().lower(), None)
def is_flash(mime_type: str) -> bool:
return mime_type.lower() == "application/x-shockwave-flash"
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/webm", "video/x-flv")
def is_image(mime_type: str) -> bool:

Binary file not shown.

View file

@ -19,6 +19,7 @@ from szurubooru.func import mime
("heif.heif", "image/heif"),
("heic.heic", "image/heic"),
("heic-heix.heic", "image/heic"),
("flv.flv", "video/x-flv"),
("text.txt", "application/octet-stream"),
],
)
@ -72,6 +73,8 @@ def test_is_flash(input_mime_type, expected_state):
("VIDEO/MP4", True),
("video/anything_else", False),
("application/ogg", True),
("video/x-flv", True),
("VIDEO/X-FLV", True),
("not a video", False),
],
)

View file

@ -462,6 +462,13 @@ def test_update_post_source_with_too_long_string():
model.Post.TYPE_FLASH,
"1_244c8840887984c4.swf",
),
(
False,
"flv.flv",
"video/x-flv",
model.Post.TYPE_VIDEO,
"1_244c8840887984c4.flv",
),
],
)
def test_update_post_content_for_new_post(