[twitter] Media info is not always in the first entity

Fixes #8704
This commit is contained in:
Yen Chi Hsuan 2016-03-03 14:42:49 +08:00
parent c8398a9b87
commit 03879ff054
1 changed files with 21 additions and 1 deletions

View File

@ -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):