diff --git a/src/modules/processing/match.js b/src/modules/processing/match.js index 3317dc6c..12c0bc10 100644 --- a/src/modules/processing/match.js +++ b/src/modules/processing/match.js @@ -36,7 +36,8 @@ export default async function(host, patternMatch, url, lang, obj) { switch (host) { case "twitter": r = await twitter({ - id: patternMatch["id"] + id: patternMatch.id, + index: patternMatch.index - 1 }); break; case "vk": diff --git a/src/modules/processing/services/twitter.js b/src/modules/processing/services/twitter.js index a02b792c..ea5f4818 100644 --- a/src/modules/processing/services/twitter.js +++ b/src/modules/processing/services/twitter.js @@ -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: diff --git a/src/modules/processing/servicesConfig.json b/src/modules/processing/servicesConfig.json index e85b9070..02bf393a 100644 --- a/src/modules/processing/servicesConfig.json +++ b/src/modules/processing/servicesConfig.json @@ -15,7 +15,7 @@ "alias": "twitter videos & voice", "altDomains": ["x.com", "vxtwitter.com", "fixvx.com"], "subdomains": ["mobile"], - "patterns": [":user/status/:id", ":user/status/:id/video/:v"], + "patterns": [":user/status/:id", ":user/status/:id/video/:index"], "enabled": true }, "vk": {