mirror of
https://github.com/wukko/cobalt.git
synced 2025-05-25 02:52:11 +02:00
api/twitter: add support for saving media from ad cards
This commit is contained in:
parent
e7f2244579
commit
f36c749692
@ -162,6 +162,19 @@ const extractGraphqlMedia = async (tweet, dispatcher, id, guestToken, cookie) =>
|
||||
repostedTweet = baseTweet?.retweeted_status_result?.result.tweet.legacy.extended_entities;
|
||||
}
|
||||
|
||||
if (tweetResult.card?.legacy?.binding_values?.length) {
|
||||
const card = JSON.parse(tweetResult.card.legacy.binding_values[0].value?.string_value);
|
||||
|
||||
if (!["video_website", "image_website"].includes(card?.type) ||
|
||||
!card?.media_entities ||
|
||||
card?.component_objects?.media_1?.type !== "media") {
|
||||
return;
|
||||
}
|
||||
|
||||
const mediaId = card.component_objects?.media_1?.data?.id;
|
||||
return [card.media_entities[mediaId]];
|
||||
}
|
||||
|
||||
return (repostedTweet?.media || baseTweet?.extended_entities?.media);
|
||||
}
|
||||
|
||||
|
@ -217,5 +217,14 @@
|
||||
"code": 200,
|
||||
"status": "tunnel"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "video in an ad card",
|
||||
"url": "https://x.com/igorbrigadir/status/1611399816487084033?s=46",
|
||||
"params": {},
|
||||
"expected": {
|
||||
"code": 200,
|
||||
"status": "redirect"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user