]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cspan.py
fbefd37d09a98bb19c82b4c09b7b08c99d147d35
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' : '8e44ce11f0f725527daccc453f553eb0' ,
25 'title' : 'Attorney General Eric Holder on Voting Rights Act Decision' ,
26 'description' : 'Attorney General Eric Holder spoke 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 until Congress established new guidelines for review.' ,
28 'skip' : 'Regularly fails on travis, for unknown reasons' ,
30 'url' : 'http://www.c-span.org/video/?c4486943/cspan-international-health-care-models' ,
31 # For whatever reason, the served video alternates between
36 'title' : 'International Health Care Models' ,
37 'description' : 'md5:7a985a2d595dba00af3d9c9f0783c967' ,
40 'url' : 'http://www.c-span.org/video/?318608-1/gm-ignition-switch-recall' ,
41 'md5' : '446562a736c6bf97118e389433ed88d4' ,
45 'title' : 'General Motors Ignition Switch Recall' ,
47 'description' : 'md5:70c7c3b8fa63fa60d42772440596034c'
50 # Video from senate.gov
51 'url' : 'http://www.c-span.org/video/?104517-1/immigration-reforms-needed-protect-skilled-american-workers' ,
53 'id' : 'judiciary031715' ,
55 'title' : 'Immigration Reforms Needed to Protect Skilled American Workers' ,
59 def _real_extract ( self
, url
):
60 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
61 page_id
= mobj
. group ( 'id' )
62 webpage
= self
._ download
_ webpage
( url
, page_id
)
63 video_id
= self
._ search
_ regex
( r
'progid=\' ?
([ 0 - 9 ]+) \' ?
> ', webpage, ' video
id ')
65 description = self._html_search_regex(
67 # The full description
68 r' < div
class = \' expandable
\' >(.* ?
)< a href
= \' #\'',
69 # If the description is small enough the other div is not
70 # present, otherwise this is a stripped version
71 r
'<p class=\' initial
\' >(.* ?
)</ p
> '
73 webpage, ' description
', flags=re.DOTALL, default=None)
75 info_url = ' http
:// c
- spanvideo
. org
/ videoLibrary
/ assets
/ player
/ ajax
- player
. php?os
= android
& html5
= program
& id = ' + video_id
76 data = self._download_json(info_url, video_id)
78 doc = self._download_xml(
79 ' http
:// www
. c
- span
. org
/ common
/ services
/ flashXml
. php?programid
= ' + video_id,
82 title = find_xpath_attr(doc, ' .// string
', ' name
', ' title
').text
83 thumbnail = find_xpath_attr(doc, ' .// string
', ' name
', ' poster
').text
85 senate_isvp_url = SenateISVPIE._search_iframe_url(webpage)
87 surl = smuggle_url(senate_isvp_url, {' force_title
': title})
88 return self.url_result(surl, ' SenateISVP
', video_id, title)
90 files = data[' video
'][' files
']
92 capfile = data[' video
'][' capfile
'][' #text']
97 'id' : ' %s _ %d ' % ( video_id
, partnum
+ 1 ),
99 title
if len ( files
) == 1 else
100 ' %s part %d ' % ( title
, partnum
+ 1 )),
101 'url' : unescapeHTML ( f
[ 'path' ][ '#text' ]),
102 'description' : description
,
103 'thumbnail' : thumbnail
,
104 'duration' : int_or_none ( f
. get ( 'length' , {}). get ( '#text' )),
108 'ext' : determine_ext ( capfile
, 'dfxp' )
110 } if capfile
else None ,
111 } for partnum
, f
in enumerate ( files
)]
113 if len ( entries
) == 1 :
114 entry
= dict ( entries
[ 0 ])
115 entry
[ 'id' ] = video_id