瀏覽代碼

[canvas] Improve subtitles (Closes #8537)

Sergey M․ 9 年之前
父節點
當前提交
fd7a3ea4a4
共有 1 個文件被更改,包括 7 次插入8 次删除
  1. 7 8
      youtube_dl/extractor/canvas.py

+ 7 - 8
youtube_dl/extractor/canvas.py

@@ -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,