[Canvas] Add subtitles
authorRobin Houtevelts <robin@houtevelts.com>
Sat, 13 Feb 2016 00:12:44 +0000 (01:12 +0100)
committerSergey M․ <dstftw@gmail.com>
Mon, 15 Feb 2016 14:50:03 +0000 (20:50 +0600)
youtube_dl/extractor/canvas.py

index ee19ff83627f4daa1b2947533a2414acdc931cbe..16f458d6c8cae277a99bcbf453db1dbbd285df3c 100644 (file)
@@ -53,6 +53,15 @@ 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,
+                }]
 
         return {
             'id': video_id,
@@ -62,4 +71,5 @@ class CanvasIE(InfoExtractor):
             'formats': formats,
             'duration': float_or_none(data.get('duration'), 1000),
             'thumbnail': data.get('posterImageUrl'),
+            'subtitles': subtitles,
         }