Skip to content

best way to save what you love

twitter: fix gif encoding for multi-media tweets

dumbmoron558e466478bc
diff --git a/src/modules/processing/match.js b/src/modules/processing/match.js
index 0d5980ca..cc2516f2 100644
--- a/src/modules/processing/match.js
+++ b/src/modules/processing/match.js
@@ -39,7 +39,7 @@ export default async function(host, patternMatch, url, lang, obj) {
r = await twitter({
id: patternMatch.id,
index: patternMatch.index - 1,
- toGif: obj.twitterGif
+ toGif: !!obj.twitterGif
});
break;
case "vk":
diff --git a/src/modules/processing/services/twitter.js b/src/modules/processing/services/twitter.js
index ee6a9f12..97371035 100644
--- a/src/modules/processing/services/twitter.js
+++ b/src/modules/processing/services/twitter.js
@@ -114,22 +114,23 @@ export default async function({ id, index, toGif }) {
isGif: media[0].type === "animated_gif"
};
default:
- const picker = media.map((video, i) => {
- let url = bestQuality(video.video_info.variants);
- if (needsFixing(video)) {
+ const picker = media.map((content, i) => {
+ let url = bestQuality(content.video_info.variants);
+ const shouldRenderGif = content.type === 'animated_gif' && toGif;
+
+ if (needsFixing(content) || shouldRenderGif) {
url = createStream({
service: 'twitter',
- type: 'remux',
+ type: shouldRenderGif ? 'gif' : 'remux',
u: url,
- filename: `twitter_${id}_${i + 1}.mp4`,
- isGif: media[0].type === "animated_gif",
- toGif: toGif ?? false
+ filename: `twitter_${id}_${i + 1}.mp4`
})
}
+
return {
type: 'video',
url,
- thumb: video.media_url_https,
+ thumb: content.media_url_https,
}
});
return { picker };