[twitter] if the tweet contains video from another tweet, download it

This commit is contained in:
Mort Yao 2022-10-23 18:46:33 +02:00
parent 9f608990ee
commit 8ef66a3173
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -62,6 +62,13 @@ def twitter_download(url, output_dir='.', merge=True, info_only=False, **kwargs)
# if the tweet contains media, download them # if the tweet contains media, download them
media = info['globalObjects']['tweets'][item_id]['extended_entities']['media'] media = info['globalObjects']['tweets'][item_id]['extended_entities']['media']
elif 'entities' in info['globalObjects']['tweets'][item_id]:
# if the tweet contains video from another tweet, download it
# FIXME: multiple urls?
expanded_url = info['globalObjects']['tweets'][item_id]['entities']['urls'][0]['expanded_url']
item_id = r1(r'/(\d+)/video', expanded_url)
assert False
elif info['globalObjects']['tweets'][item_id].get('is_quote_status') == True: elif info['globalObjects']['tweets'][item_id].get('is_quote_status') == True:
# if the tweet does not contain media, but it quotes a tweet # if the tweet does not contain media, but it quotes a tweet
# and the quoted tweet contains media, download them # and the quoted tweet contains media, download them