From d4ad60c11d63d8a43eb50c81201c74a9f0d385f0 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Sat, 9 Dec 2017 15:25:01 -0800 Subject: [PATCH] Support video file previews --- client/views/msg_preview.tpl | 38 ++++++++++++++++++++-------------- src/plugins/irc-events/link.js | 14 ++++++++++++- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/client/views/msg_preview.tpl b/client/views/msg_preview.tpl index 3f7f2d10..7f09bc5c 100644 --- a/client/views/msg_preview.tpl +++ b/client/views/msg_preview.tpl @@ -4,23 +4,29 @@ - {{else}} - {{#equal type "audio"}} - - {{else}} - {{#if thumb}} - - - - {{/if}} - -
{{head}}
-
{{body}}
+ {{/equal}} + {{#equal type "audio"}} + + {{/equal}} + {{#equal type "video"}} + + {{/equal}} + {{#equal type "link"}} + {{#if thumb}} +
+ - {{/equal}} + {{/if}} + +
{{head}}
+
{{body}}
+
{{/equal}} {{/preview}} diff --git a/src/plugins/irc-events/link.js b/src/plugins/irc-events/link.js index cd3ea0d9..45acaf84 100644 --- a/src/plugins/irc-events/link.js +++ b/src/plugins/irc-events/link.js @@ -120,6 +120,18 @@ function parse(msg, preview, res, client) { } preview.type = "audio"; preview.res = res.type; + + break; + + case "video/webm": + case "video/ogg": + case "video/mp4": + if (!preview.link.startsWith("https://")) { + break; + } + preview.res = res.type; + preview.type = "video"; + break; default: @@ -186,7 +198,7 @@ function fetch(uri, cb) { if (contentLength > limit) { req.abort(); } - } else if (/^audio\/.+/.test(res.headers["content-type"])) { + } else if (/^(audio|video)\/.+/.test(res.headers["content-type"])) { req.abort(); // ensure server doesn't download the audio file } else { // if not image, limit download to 50kb, since we need only meta tags