Ensure that video/gif embeds in tweets are also cached locally

This commit is contained in:
Jocelyn Badgley (Twipped)
2021-08-27 11:32:44 -07:00
parent 68cd84ccad
commit 5992501a01
3 changed files with 20 additions and 2 deletions

View File

@@ -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;
});