]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[canvas] Improve subtitles (Closes #8537)
authorSergey M․ <dstftw@gmail.com>
Mon, 15 Feb 2016 14:54:01 +0000 (20:54 +0600)
committerSergey M․ <dstftw@gmail.com>
Mon, 15 Feb 2016 14:54:01 +0000 (20:54 +0600)
youtube_dl/extractor/canvas.py

index 16f458d6c8cae277a99bcbf453db1dbbd285df3c..54b535ae9294f2dbe4aee4df15c7996db2d1d2d6 100644 (file)
@@ -53,15 +53,14 @@ class CanvasIE(InfoExtractor):
                     'url': format_url,
                 })
         self._sort_formats(formats)
-        
+
         subtitles = {}
-        for target in data['subtitleUrls']:
-            format_url, format_type = target.get('url'), target.get('type')
-            if format_type == 'CLOSED':
-                subtitles['nl'] = [{
-                    'ext': 'vtt',
-                    'url': format_url,
-                }]
+        subtitle_urls = data.get('subtitleUrls')
+        if isinstance(subtitle_urls, list):
+            for subtitle in subtitle_urls:
+                subtitle_url = subtitle.get('url')
+                if subtitle_url and subtitle.get('type') == 'CLOSED':
+                    subtitles.setdefault('nl', []).append({'url': subtitle_url})
 
         return {
             'id': video_id,