twitter: downloading specific video if given index

This commit is contained in:
dumbmoron 2024-01-05 12:21:59 +00:00
parent 7b41dfef9e
commit ed2c63f9a4
No known key found for this signature in database
GPG key ID: C59997C76C6A8E5F
3 changed files with 9 additions and 4 deletions

View file

@ -71,7 +71,7 @@ const requestTweet = (tweetId, token) => {
});
}
export default async function({ id }) {
export default async function({ id, index }) {
let guestToken = await getGuestToken();
if (!guestToken) return { error: 'ErrorCouldntFetch' };
@ -92,10 +92,14 @@ export default async function({ id }) {
const baseTweet = tweet.data.tweetResult.result.legacy,
repostedTweet = baseTweet.retweeted_status_result?.result.legacy.extended_entities;
const media = (
let media = (
repostedTweet?.media || baseTweet.extended_entities.media
)?.filter(m => ['video', 'animated_gif'].includes(m.type));
if (index < media?.length) {
media = [ media[index] ];
}
switch (media?.length) {
case undefined:
case 0: