diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2016-03-03 14:42:49 +0800 |
---|---|---|
committer | Yen Chi Hsuan <yan12125@gmail.com> | 2016-03-03 14:42:49 +0800 |
commit | 03879ff0547b6d1b96c530075cd99f99b8c74a2b (patch) | |
tree | a47688c267b6afdc0dfdbb3cee28c157f2da2f48 /youtube_dl | |
parent | c8398a9b87dadf4cd8464e1ab77d2874d9ae484b (diff) |
[twitter] Media info is not always in the first entity
Fixes #8704
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/twitter.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/youtube_dl/extractor/twitter.py b/youtube_dl/extractor/twitter.py index 97a4a5948..67762a003 100644 --- a/youtube_dl/extractor/twitter.py +++ b/youtube_dl/extractor/twitter.py @@ -124,7 +124,12 @@ class TwitterCardIE(TwitterBaseIE): 'url': self._get_vmap_video_url(vmap_url, video_id), }) - media_info = config.get('status', {}).get('entities', [{}])[0].get('mediaInfo', {}) + media_info = None + + for entity in config.get('status', {}).get('entities', []): + if 'mediaInfo' in entity: + media_info = entity['mediaInfo'] + if media_info: for media_variant in media_info['variants']: media_url = media_variant['url'] @@ -221,6 +226,21 @@ class TwitterIE(InfoExtractor): # Test case of TwitterCardIE 'skip_download': True, }, + }, { + 'url': 'https://twitter.com/jaydingeer/status/700207533655363584', + 'md5': '', + 'info_dict': { + 'id': '700207533655363584', + 'ext': 'mp4', + 'title': 'jay - BEAT PROD: @suhmeduh #Damndaniel', + 'description': 'jay on Twitter: "BEAT PROD: @suhmeduh https://t.co/HBrQ4AfpvZ #Damndaniel https://t.co/byBooq2ejZ"', + 'thumbnail': 're:^https?://.*\.jpg', + 'uploader': 'jay', + 'uploader_id': 'jaydingeer', + }, + 'params': { + 'skip_download': True, # requires ffmpeg + }, }] def _real_extract(self, url): |