-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to download video from sponsored (ad/paid) tweets #6
Comments
Never seen that. |
API endpoint* that I use (when you click on the button over the video) does not contain It requires to use a different endpoint**, but it also requires an additional investigations for me to implement it. * |
Found another weird ad tweet. |
I added a fix to correctly show the error. eb8856b It's possible to download it, it requires to do some extra action when It's so boring to parse Twitter's JSON responses. /**
* Returns an array like this (https://x.com/kirachem/status/1805456475893928166):
* [
{
"screen_name": "kirachem",
"tweet_id": "1805456475893928166",
"download_url": "https://video.twimg.com/amplify_video/1805450004041285634/vid/avc1/1080x1080/2da-wiS9XJ42-9rv.mp4?tag=16",
"type": "video",
"type_original": "video",
"index": 0,
"type_index": 0,
"type_index_original": 0,
"preview_url": "https://pbs.twimg.com/media/GQ4_SPoakAAnW8e.jpg",
"media_id": "1805450004041285634",
"media_key": "13_1805450004041285634",
"expanded_url": "https://twitter.com/kirachem/status/1805456475893928166/video/1",
"short_expanded_url": "pic.twitter.com/VnOcUSsGaC",
"short_tweet_url": "https://t.co/VnOcUSsGaC",
"tweet_text": "Bunny Tifa (Cloud's POV)"
}
]
*/
static async getTweetMedias(tweetId) {
const tweetJson = await API.getTweetJson(tweetId);
const {tweetResult, tweetLegacy, tweetUser} = API.parseTweetJson(tweetJson, tweetId);
let result = API.parseTweetLegacyMedias(tweetResult, tweetLegacy, tweetUser);
if (tweetResult.quoted_status_result && tweetResult.quoted_status_result.result /* check is the qouted tweet not deleted */) {
const tweetResultQuoted = tweetResult.quoted_status_result.result;
const tweetLegacyQuoted = tweetResultQuoted.legacy;
const tweetUserQuoted = tweetResultQuoted.core.user_results.result;
result = [...result, ...API.parseTweetLegacyMedias(tweetResultQuoted, tweetLegacyQuoted, tweetUserQuoted)];
}
// --- HERE ---
if (result.length === 0) {
if (tweetResult.card?.legacy?.binding_values?.[0]) {
const obj = tweetResult.card.legacy.binding_values[0];
if (obj.key === "unified_card" && obj.value && obj.value.type === "STRING") {
const value = JSON.parse(obj.value.string_value);
console.log("!!!", "todo continue here", value);
// TODO: find mp4 and the related data, then return a fake result (an array with a custom object, see the example return value)
}
}
}
// --- HERE ---
return result;
} Maybe it's possible to reuse |
Possible, it's just better to find mp4 url with RegEx, then just download it using the username and tweeId from the location url for the filename, without spending time for the parsing large json. |
ArknightsEN has a video tweet here and after playing the video, the red script button doesn't seem to do anything.
The text was updated successfully, but these errors were encountered: