1 from __future__ import unicode_literals
5 from .common import InfoExtractor
13 from .senateisvp import SenateISVPIE
16 class CSpanIE(InfoExtractor):
17 _VALID_URL = r'http://(?:www\.)?c-span\.org/video/\?(?P<id>[0-9a-f]+)'
20 'url': 'http://www.c-span.org/video/?313572-1/HolderonV',
21 'md5': '067803f994e049b455a58b16e5aab442',
25 'title': 'Attorney General Eric Holder on Voting Rights Act Decision',
26 'description': 'Attorney General Eric Holder speaks to reporters following the Supreme Court decision in [Shelby County v. Holder], in which the court ruled that the preclearance provisions of the Voting Rights Act could not be enforced.',
28 'skip': 'Regularly fails on travis, for unknown reasons',
30 'url': 'http://www.c-span.org/video/?c4486943/cspan-international-health-care-models',
31 'md5': '4eafd1e91a75d2b1e6a3cbd0995816a2',
35 'title': 'CSPAN - International Health Care Models',
36 'description': 'md5:7a985a2d595dba00af3d9c9f0783c967',
39 'url': 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall',
40 'md5': '446562a736c6bf97118e389433ed88d4',
44 'title': 'General Motors Ignition Switch Recall',
46 'description': 'md5:118081aedd24bf1d3b68b3803344e7f3'
49 # Video from senate.gov
50 'url': 'http://www.c-span.org/video/?104517-1/immigration-reforms-needed-protect-skilled-american-workers',
52 'id': 'judiciary031715',
54 'title': 'Immigration Reforms Needed to Protect Skilled American Workers',
58 def _real_extract(self, url):
59 video_id = self._match_id(url)
60 webpage = self._download_webpage(url, video_id)
61 matches = re.search(r'data-(prog|clip)id=\'([0-9]+)\'', webpage)
63 video_type, video_id = matches.groups()
64 if video_type == 'prog':
65 video_type = 'program'
67 senate_isvp_url = SenateISVPIE._search_iframe_url(webpage)
69 title = self._og_search_title(webpage)
70 surl = smuggle_url(senate_isvp_url, {'force_title': title})
71 return self.url_result(surl, 'SenateISVP', video_id, title)
73 data = self._download_json(
74 'http://c-spanvideo.org/videoLibrary/assets/player/ajax-player.php?os=android&html5=%s&id=%s' % (video_type, video_id),
77 doc = self._download_xml(
78 'http://www.c-span.org/common/services/flashXml.php?%sid=%s' % (video_type, video_id),
81 description = self._html_search_meta('description', webpage)
83 title = find_xpath_attr(doc, './/string', 'name', 'title').text
84 thumbnail = find_xpath_attr(doc, './/string', 'name', 'poster').text
86 files = data['video']['files']
88 capfile = data['video']['capfile']['#text']
93 'id': '%s_%d' % (video_id, partnum + 1),
95 title if len(files) == 1 else
96 '%s part %d' % (title, partnum + 1)),
97 'url': unescapeHTML(f['path']['#text']),
98 'description': description,
99 'thumbnail': thumbnail,
100 'duration': int_or_none(f.get('length', {}).get('#text')),
104 'ext': determine_ext(capfile, 'dfxp')
106 } if capfile else None,
107 } for partnum, f in enumerate(files)]
109 if len(entries) == 1:
110 entry = dict(entries[0])
111 entry['id'] = 'c' + video_id if video_type == 'clip' else video_id
118 'id': 'c' + video_id if video_type == 'clip' else video_id,