[twitter] show the warning message if login required

This commit is contained in:
Mort Yao 2022-04-22 19:17:26 +02:00
parent 43e14887a3
commit 355e22584c
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -51,7 +51,12 @@ def twitter_download(url, output_dir='.', merge=True, info_only=False, **kwargs)
api_content = get_content(api_url, headers={'authorization': authorization, 'x-guest-token': guest_token}) api_content = get_content(api_url, headers={'authorization': authorization, 'x-guest-token': guest_token})
info = json.loads(api_content) info = json.loads(api_content)
if 'extended_entities' in info['globalObjects']['tweets'][item_id]: if item_id not in info['globalObjects']['tweets']:
# something wrong here
log.w(info['timeline']['instructions'][0]['addEntries']['entries'][0]['content']['item']['content']['tombstone']['tombstoneInfo']['richText']['text'])
return
elif 'extended_entities' in info['globalObjects']['tweets'][item_id]:
# 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']