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; 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; return media;
}); });

View File

@ -272,7 +272,9 @@
} }
.tweet-footer { .tweet-footer {
display: block; display: flex;
flex: 1 1 auto;
align-items: flex-end;
color: $textLight; color: $textLight;
font-size: 1em; font-size: 1em;
margin-top: 10px; margin-top: 10px;

View File

@ -52,7 +52,7 @@
</video> </video>
{{/is}} {{/is}}
{{#is type 'animated_gif'}} {{#is type 'animated_gif'}}
<video controls muted loop poster="{{media_url_https}}" class="tweet-video"> <video controls autoplay muted loop poster="{{media_url_https}}" class="tweet-video">
{{#each video_info.variants}} {{#each video_info.variants}}
<source src="{{url}}" type="{{content_type}}"> <source src="{{url}}" type="{{content_type}}">
{{/each}} {{/each}}