]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[twitter] Media info is not always in the first entity
authorYen Chi Hsuan <yan12125@gmail.com>
Thu, 3 Mar 2016 06:42:49 +0000 (14:42 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Thu, 3 Mar 2016 06:42:49 +0000 (14:42 +0800)
Fixes #8704

youtube_dl/extractor/twitter.py

index 97a4a5948aceb84e9378dcad5bdd6e5cc95c3555..67762a003075c71c8067bd763772642d77888d93 100644 (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):