mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-17 22:00:00 +00:00
twitter: fix gif encoding for multi-media tweets
merge pull request #327 from dumbmoron/twitter-multi-gif-fix
This commit is contained in:
commit
debe8ba8aa
2 changed files with 10 additions and 9 deletions
|
@ -39,7 +39,7 @@ export default async function(host, patternMatch, url, lang, obj) {
|
||||||
r = await twitter({
|
r = await twitter({
|
||||||
id: patternMatch.id,
|
id: patternMatch.id,
|
||||||
index: patternMatch.index - 1,
|
index: patternMatch.index - 1,
|
||||||
toGif: obj.twitterGif
|
toGif: !!obj.twitterGif
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "vk":
|
case "vk":
|
||||||
|
|
|
@ -114,22 +114,23 @@ export default async function({ id, index, toGif }) {
|
||||||
isGif: media[0].type === "animated_gif"
|
isGif: media[0].type === "animated_gif"
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
const picker = media.map((video, i) => {
|
const picker = media.map((content, i) => {
|
||||||
let url = bestQuality(video.video_info.variants);
|
let url = bestQuality(content.video_info.variants);
|
||||||
if (needsFixing(video)) {
|
const shouldRenderGif = content.type === 'animated_gif' && toGif;
|
||||||
|
|
||||||
|
if (needsFixing(content) || shouldRenderGif) {
|
||||||
url = createStream({
|
url = createStream({
|
||||||
service: 'twitter',
|
service: 'twitter',
|
||||||
type: 'remux',
|
type: shouldRenderGif ? 'gif' : 'remux',
|
||||||
u: url,
|
u: url,
|
||||||
filename: `twitter_${id}_${i + 1}.mp4`,
|
filename: `twitter_${id}_${i + 1}.mp4`
|
||||||
isGif: media[0].type === "animated_gif",
|
|
||||||
toGif: toGif ?? false
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
url,
|
url,
|
||||||
thumb: video.media_url_https,
|
thumb: content.media_url_https,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return { picker };
|
return { picker };
|
||||||
|
|
Loading…
Reference in a new issue