From 03879ff0547b6d1b96c530075cd99f99b8c74a2b Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Thu, 3 Mar 2016 14:42:49 +0800 Subject: [PATCH] [twitter] Media info is not always in the first entity Fixes #8704 --- youtube_dl/extractor/twitter.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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): -- 2.22.2