Merge 7c43c185f5
into d7d2a151a8
This commit is contained in:
commit
8a6d72ea49
8 changed files with 29 additions and 4 deletions
|
@ -26,6 +26,7 @@ const external_js = [
|
||||||
'marked',
|
'marked',
|
||||||
'mousetrap',
|
'mousetrap',
|
||||||
'nprogress',
|
'nprogress',
|
||||||
|
'flv.js',
|
||||||
'superagent',
|
'superagent',
|
||||||
'underscore',
|
'underscore',
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const flvjs = require("flv.js");
|
||||||
const iosCorrectedInnerHeight = require("ios-inner-height");
|
const iosCorrectedInnerHeight = require("ios-inner-height");
|
||||||
const router = require("../router.js");
|
const router = require("../router.js");
|
||||||
const views = require("../util/views.js");
|
const views = require("../util/views.js");
|
||||||
|
@ -49,6 +50,16 @@ class PostMainView {
|
||||||
postContainerNode.querySelector(".post-overlay"),
|
postContainerNode.querySelector(".post-overlay"),
|
||||||
ctx.post
|
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") {
|
if (ctx.post.type === "video" || ctx.post.type === "flash") {
|
||||||
this._postContentControl.disableOverlay();
|
this._postContentControl.disableOverlay();
|
||||||
|
|
|
@ -163,7 +163,7 @@ class PostUploadView extends events.EventTarget {
|
||||||
this._contentInputNode,
|
this._contentInputNode,
|
||||||
{
|
{
|
||||||
extraText:
|
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,
|
allowUrls: true,
|
||||||
allowMultiple: true,
|
allowMultiple: true,
|
||||||
lock: false,
|
lock: false,
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dompurify": "^2.0.17",
|
"dompurify": "^2.0.17",
|
||||||
|
"flv.js": "^1.6.2",
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
"ios-inner-height": "^1.0.3",
|
"ios-inner-height": "^1.0.3",
|
||||||
"js-cookie": "^2.2.0",
|
"js-cookie": "^2.2.0",
|
||||||
|
|
|
@ -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[0:3] == b"FLV":
|
||||||
|
return "video/x-flv"
|
||||||
|
|
||||||
return "application/octet-stream"
|
return "application/octet-stream"
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,17 +58,16 @@ def get_extension(mime_type: str) -> Optional[str]:
|
||||||
"image/heic": "heic",
|
"image/heic": "heic",
|
||||||
"video/mp4": "mp4",
|
"video/mp4": "mp4",
|
||||||
"video/webm": "webm",
|
"video/webm": "webm",
|
||||||
|
"video/x-flv": "flv",
|
||||||
"application/octet-stream": "dat",
|
"application/octet-stream": "dat",
|
||||||
}
|
}
|
||||||
return extension_map.get((mime_type or "").strip().lower(), None)
|
return extension_map.get((mime_type or "").strip().lower(), None)
|
||||||
|
|
||||||
|
|
||||||
def is_flash(mime_type: str) -> bool:
|
def is_flash(mime_type: str) -> bool:
|
||||||
return mime_type.lower() == "application/x-shockwave-flash"
|
return mime_type.lower() == "application/x-shockwave-flash"
|
||||||
|
|
||||||
|
|
||||||
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/webm", "video/x-flv")
|
||||||
|
|
||||||
|
|
||||||
def is_image(mime_type: str) -> bool:
|
def is_image(mime_type: str) -> bool:
|
||||||
|
|
BIN
server/szurubooru/tests/assets/flv.flv
Normal file
BIN
server/szurubooru/tests/assets/flv.flv
Normal file
Binary file not shown.
|
@ -19,6 +19,7 @@ from szurubooru.func import mime
|
||||||
("heif.heif", "image/heif"),
|
("heif.heif", "image/heif"),
|
||||||
("heic.heic", "image/heic"),
|
("heic.heic", "image/heic"),
|
||||||
("heic-heix.heic", "image/heic"),
|
("heic-heix.heic", "image/heic"),
|
||||||
|
("flv.flv", "video/x-flv"),
|
||||||
("text.txt", "application/octet-stream"),
|
("text.txt", "application/octet-stream"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -72,6 +73,8 @@ def test_is_flash(input_mime_type, expected_state):
|
||||||
("VIDEO/MP4", True),
|
("VIDEO/MP4", True),
|
||||||
("video/anything_else", False),
|
("video/anything_else", False),
|
||||||
("application/ogg", True),
|
("application/ogg", True),
|
||||||
|
("video/x-flv", True),
|
||||||
|
("VIDEO/X-FLV", True),
|
||||||
("not a video", False),
|
("not a video", False),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -462,6 +462,13 @@ def test_update_post_source_with_too_long_string():
|
||||||
model.Post.TYPE_FLASH,
|
model.Post.TYPE_FLASH,
|
||||||
"1_244c8840887984c4.swf",
|
"1_244c8840887984c4.swf",
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
False,
|
||||||
|
"flv.flv",
|
||||||
|
"video/x-flv",
|
||||||
|
model.Post.TYPE_VIDEO,
|
||||||
|
"1_244c8840887984c4.flv",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_update_post_content_for_new_post(
|
def test_update_post_content_for_new_post(
|
||||||
|
|
Reference in a new issue