Fix some issues with tweet video caching

This commit is contained in:
Jocelyn Badgley (Twipped) 2021-08-27 11:40:01 -07:00
parent 9a7586a2c3
commit 219680d783

View File

@ -131,12 +131,13 @@ module.exports = exports = function (tweets) {
if (media.video_info && media.video_info.variants) { if (media.video_info && media.video_info.variants) {
media.video_info.variants = media.video_info.variants.map((variant) => { media.video_info.variants = media.video_info.variants.map((variant) => {
if (!variant.url) return variant; if (!variant.url || !variant.bitrate) return variant;
const fname = path.basename(variant.url).split('?')[0];
const mediaItem = { const mediaItem = {
input: variant.url, input: variant.url,
output: `tweets/${tweet.id_str}/${path.basename(variant.url)}`, output: `tweets/${tweet.id_str}/${fname}`,
cache: `twitter-entities/${tweet.id_str}/${path.basename(variant.url)}`, cache: `twitter-entities/${tweet.id_str}/${fname}`,
}; };
tweet.media.push(mediaItem); tweet.media.push(mediaItem);
variant.url = '/' + mediaItem.output; variant.url = '/' + mediaItem.output;