mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-17 22:00:00 +00:00
twitter: downloading specific video if given index
This commit is contained in:
parent
7b41dfef9e
commit
ed2c63f9a4
3 changed files with 9 additions and 4 deletions
|
@ -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":
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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": {
|
||||
|
|
Loading…
Reference in a new issue