]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[globo] extract subtitles(closes #22713)
authorRemita Amine <remitamine@gmail.com>
Tue, 15 Oct 2019 18:54:53 +0000 (19:54 +0100)
committerRemita Amine <remitamine@gmail.com>
Tue, 15 Oct 2019 18:54:53 +0000 (19:54 +0100)
youtube_dl/extractor/globo.py

index b9c400a5737ae99f2842dc121326f0aa16cd274d..9ad1d95fb8ea76230e2661a96f8f98507792838b 100644 (file)
@@ -102,10 +102,18 @@ class GloboIE(InfoExtractor):
         title = video['title']
 
         formats = []
+        subtitles = {}
         for resource in video['resources']:
             resource_id = resource.get('_id')
             resource_url = resource.get('url')
-            if not resource_id or not resource_url:
+            resource_type = resource.get('type')
+            if not resource_url or (resource_type == 'media' and not resource_id) or resource_type not in ('subtitle', 'media'):
+                continue
+
+            if resource_type == 'subtitle':
+                subtitles.setdefault(resource.get('language') or 'por', []).append({
+                    'url': resource_url,
+                })
                 continue
 
             security = self._download_json(
@@ -165,7 +173,8 @@ class GloboIE(InfoExtractor):
             'duration': duration,
             'uploader': uploader,
             'uploader_id': uploader_id,
-            'formats': formats
+            'formats': formats,
+            'subtitles': subtitles,
         }