]> gitweb @ CieloNegro.org - youtube-dl.git/blobdiff - youtube_dl/extractor/twitter.py
[twitter] Fix extraction (closes #8966)
[youtube-dl.git] / youtube_dl / extractor / twitter.py
index 67762a003075c71c8067bd763772642d77888d93..602538e5cc09ab89214caff794358a5702e45be0 100644 (file)
@@ -102,20 +102,23 @@ class TwitterCardIE(TwitterBaseIE):
             r'data-(?:player-)?config="([^"]+)"', webpage, 'data player config'),
             video_id)
 
-        playlist = config.get('playlist')
-        if playlist:
-            video_url = playlist[0]['source']
-
-            f = {
-                'url': video_url,
-            }
-
+        def _search_dimensions_in_video_url(a_format, video_url):
             m = re.search(r'/(?P<width>\d+)x(?P<height>\d+)/', video_url)
             if m:
-                f.update({
+                a_format.update({
                     'width': int(m.group('width')),
                     'height': int(m.group('height')),
                 })
+
+        video_url = config.get('video_url') or config.get('playlist', [{}])[0].get('source')
+
+        if video_url:
+            f = {
+                'url': video_url,
+            }
+
+            _search_dimensions_in_video_url(f, video_url)
+
             formats.append(f)
 
         vmap_url = config.get('vmapUrl') or config.get('vmap_url')
@@ -148,6 +151,8 @@ class TwitterCardIE(TwitterBaseIE):
                     if not a_format['vbr']:
                         del a_format['vbr']
 
+                    _search_dimensions_in_video_url(a_format, media_url)
+
                     formats.append(a_format)
 
             duration = float_or_none(media_info.get('duration', {}).get('nanos'), scale=1e9)
@@ -179,7 +184,6 @@ class TwitterIE(InfoExtractor):
             'ext': 'mp4',
             'title': 'FREE THE NIPPLE - FTN supporters on Hollywood Blvd today!',
             'thumbnail': 're:^https?://.*\.jpg',
-            'duration': 12.922,
             'description': 'FREE THE NIPPLE on Twitter: "FTN supporters on Hollywood Blvd today! http://t.co/c7jHH749xJ"',
             'uploader': 'FREE THE NIPPLE',
             'uploader_id': 'freethenipple',