mirror of https://github.com/ytdl-org/youtube-dl
[twitter] Add support for unified cards (closes #27826)
parent
879866a230
commit
ab9001dab5
|
@ -373,6 +373,24 @@ class TwitterIE(TwitterBaseIE):
|
||||||
'uploader_id': '1eVjYOLGkGrQL',
|
'uploader_id': '1eVjYOLGkGrQL',
|
||||||
},
|
},
|
||||||
'add_ie': ['TwitterBroadcast'],
|
'add_ie': ['TwitterBroadcast'],
|
||||||
|
}, {
|
||||||
|
# unified card
|
||||||
|
'url': 'https://twitter.com/BrooklynNets/status/1349794411333394432?s=20',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '1349794411333394432',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'md5:d1c4941658e4caaa6cb579260d85dcba',
|
||||||
|
'thumbnail': r're:^https?://.*\.jpg',
|
||||||
|
'description': 'md5:71ead15ec44cee55071547d6447c6a3e',
|
||||||
|
'uploader': 'Brooklyn Nets',
|
||||||
|
'uploader_id': 'BrooklynNets',
|
||||||
|
'duration': 324.484,
|
||||||
|
'timestamp': 1610651040,
|
||||||
|
'upload_date': '20210114',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
# Twitch Clip Embed
|
# Twitch Clip Embed
|
||||||
'url': 'https://twitter.com/GunB1g/status/1163218564784017422',
|
'url': 'https://twitter.com/GunB1g/status/1163218564784017422',
|
||||||
|
@ -433,8 +451,7 @@ class TwitterIE(TwitterBaseIE):
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
media = try_get(status, lambda x: x['extended_entities']['media'][0])
|
def extract_from_video_info(media):
|
||||||
if media and media.get('type') != 'photo':
|
|
||||||
video_info = media.get('video_info') or {}
|
video_info = media.get('video_info') or {}
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
@ -461,6 +478,10 @@ class TwitterIE(TwitterBaseIE):
|
||||||
'thumbnails': thumbnails,
|
'thumbnails': thumbnails,
|
||||||
'duration': float_or_none(video_info.get('duration_millis'), 1000),
|
'duration': float_or_none(video_info.get('duration_millis'), 1000),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
media = try_get(status, lambda x: x['extended_entities']['media'][0])
|
||||||
|
if media and media.get('type') != 'photo':
|
||||||
|
extract_from_video_info(media)
|
||||||
else:
|
else:
|
||||||
card = status.get('card')
|
card = status.get('card')
|
||||||
if card:
|
if card:
|
||||||
|
@ -493,6 +514,9 @@ class TwitterIE(TwitterBaseIE):
|
||||||
'_type': 'url',
|
'_type': 'url',
|
||||||
'url': get_binding_value('card_url'),
|
'url': get_binding_value('card_url'),
|
||||||
})
|
})
|
||||||
|
elif card_name == 'unified_card':
|
||||||
|
media_entities = self._parse_json(get_binding_value('unified_card'), twid)['media_entities']
|
||||||
|
extract_from_video_info(next(iter(media_entities.values())))
|
||||||
# amplify, promo_video_website, promo_video_convo, appplayer, ...
|
# amplify, promo_video_website, promo_video_convo, appplayer, ...
|
||||||
else:
|
else:
|
||||||
is_amplify = card_name == 'amplify'
|
is_amplify = card_name == 'amplify'
|
||||||
|
|
Loading…
Reference in New Issue