]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[konserthusetplay] Extract subtitles (#11823)
authorSergey M․ <dstftw@gmail.com>
Tue, 24 Jan 2017 16:02:20 +0000 (23:02 +0700)
committerSergey M․ <dstftw@gmail.com>
Tue, 24 Jan 2017 16:03:09 +0000 (23:03 +0700)
youtube_dl/extractor/konserthusetplay.py

index 7e6ea96964e6577d20b97ddaad76b8c1e3e62adc..3ae2aa3179e4c75ad4dad9e5cd7f8cb947f78b24 100644 (file)
@@ -2,6 +2,7 @@
 from __future__ import unicode_literals
 
 from .common import InfoExtractor
+from ..compat import compat_str
 from ..utils import (
     determine_ext,
     float_or_none,
@@ -104,6 +105,13 @@ class KonserthusetPlayIE(InfoExtractor):
         thumbnail = media.get('image')
         duration = float_or_none(media.get('duration'), 1000)
 
+        subtitles = {}
+        captions = source.get('captionsAvailableLanguages')
+        if isinstance(captions, dict):
+            for lang, subtitle_url in captions.items():
+                if lang != 'none' and isinstance(subtitle_url, compat_str):
+                    subtitles.setdefault(lang, []).append({'url': subtitle_url})
+
         return {
             'id': video_id,
             'title': title,
@@ -111,4 +119,5 @@ class KonserthusetPlayIE(InfoExtractor):
             'thumbnail': thumbnail,
             'duration': duration,
             'formats': formats,
+            'subtitles': subtitles,
         }