From 5992501a018326382a3e315bebc08ce1c491ef61 Mon Sep 17 00:00:00 2001 From: "Jocelyn Badgley (Twipped)" Date: Fri, 27 Aug 2021 11:32:44 -0700 Subject: [PATCH] Ensure that video/gif embeds in tweets are also cached locally --- build/lib/tweetparse.js | 16 ++++++++++++++++ scss/_tweet.scss | 4 +++- templates/tweet.hbs | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/build/lib/tweetparse.js b/build/lib/tweetparse.js index 760acce..05b3c38 100644 --- a/build/lib/tweetparse.js +++ b/build/lib/tweetparse.js @@ -129,6 +129,22 @@ module.exports = exports = function (tweets) { media.media_url_https = '/' + mediaItem.output; } + if (media.video_info && media.video_info.variants) { + media.video_info.variants = media.video_info.variants.map((variant) => { + if (!variant.url) return variant; + + const mediaItem = { + input: variant.url, + output: `tweets/${tweet.id_str}/${path.basename(variant.url)}`, + cache: `twitter-entities/${tweet.id_str}/${path.basename(variant.url)}`, + }; + tweet.media.push(mediaItem); + variant.url = '/' + mediaItem.output; + + return variant; + }); + } + return media; }); diff --git a/scss/_tweet.scss b/scss/_tweet.scss index b9bb080..6a5b583 100644 --- a/scss/_tweet.scss +++ b/scss/_tweet.scss @@ -272,7 +272,9 @@ } .tweet-footer { - display: block; + display: flex; + flex: 1 1 auto; + align-items: flex-end; color: $textLight; font-size: 1em; margin-top: 10px; diff --git a/templates/tweet.hbs b/templates/tweet.hbs index 04d4eb1..6166884 100644 --- a/templates/tweet.hbs +++ b/templates/tweet.hbs @@ -52,7 +52,7 @@ {{/is}} {{#is type 'animated_gif'}} -