[cspan] Extract subtitles
authorYen Chi Hsuan <yan12125@gmail.com>
Fri, 24 Apr 2015 15:46:51 +0000 (23:46 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Sat, 25 Apr 2015 15:18:27 +0000 (23:18 +0800)
youtube_dl/extractor/cspan.py

index d516b14028ae08f8de540678c7407d7b97c4595d..fbefd37d09a98bb19c82b4c09b7b08c99d147d35 100644 (file)
@@ -8,6 +8,7 @@ from ..utils import (
     unescapeHTML,
     find_xpath_attr,
     smuggle_url,
+    determine_ext,
 )
 from .senateisvp import SenateISVPIE
 
@@ -87,6 +88,10 @@ class CSpanIE(InfoExtractor):
             return self.url_result(surl, 'SenateISVP', video_id, title)
 
         files = data['video']['files']
+        try:
+            capfile = data['video']['capfile']['#text']
+        except KeyError:
+            capfile = None
 
         entries = [{
             'id': '%s_%d' % (video_id, partnum + 1),
@@ -97,6 +102,12 @@ class CSpanIE(InfoExtractor):
             'description': description,
             'thumbnail': thumbnail,
             'duration': int_or_none(f.get('length', {}).get('#text')),
+            'subtitles': {
+                'en': [{
+                    'url': capfile,
+                    'ext': determine_ext(capfile, 'dfxp')
+                }],
+            } if capfile else None,
         } for partnum, f in enumerate(files)]
 
         if len(entries) == 1: