]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cspan.py
b6552c542411c2abf639e71c955c66c34db2b007
1 from __future__
import unicode_literals
5 from . common
import InfoExtractor
13 class CSpanIE ( InfoExtractor
):
14 _VALID_URL
= r
'http://(?:www\.)?c-span\.org/video/\?(?P<id>[0-9a-f]+)'
17 'url' : 'http://www.c-span.org/video/?313572-1/HolderonV' ,
18 'md5' : '8e44ce11f0f725527daccc453f553eb0' ,
22 'title' : 'Attorney General Eric Holder on Voting Rights Act Decision' ,
23 '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.' ,
25 'skip' : 'Regularly fails on travis, for unknown reasons' ,
27 'url' : 'http://www.c-span.org/video/?c4486943/cspan-international-health-care-models' ,
28 # For whatever reason, the served video alternates between
30 #'md5': 'dbb0f047376d457f2ab8b3929cbb2d0c',
34 'title' : 'International Health Care Models' ,
35 'description' : 'md5:7a985a2d595dba00af3d9c9f0783c967' ,
39 def _real_extract ( self
, url
):
40 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
41 page_id
= mobj
. group ( 'id' )
42 webpage
= self
._ download
_ webpage
( url
, page_id
)
43 video_id
= self
._ search
_ regex
( r
'progid=\' ?
([ 0 - 9 ]+) \' ?
> ', webpage, ' video
id ')
45 description = self._html_search_regex(
47 # The full description
48 r' < div
class = \' expandable
\' >(.* ?
)< a href
= \' #\'',
49 # If the description is small enough the other div is not
50 # present, otherwise this is a stripped version
51 r
'<p class=\' initial
\' >(.* ?
)</ p
> '
53 webpage, ' description
', flags=re.DOTALL)
55 info_url = ' http
:// c
- spanvideo
. org
/ videoLibrary
/ assets
/ player
/ ajax
- player
. php?os
= android
& html5
= program
& id = ' + video_id
56 data = self._download_json(info_url, video_id)
58 doc = self._download_xml(
59 ' http
:// www
. c
- span
. org
/ common
/ services
/ flashXml
. php?programid
= ' + video_id,
62 title = find_xpath_attr(doc, ' .// string
', ' name
', ' title
').text
63 thumbnail = find_xpath_attr(doc, ' .// string
', ' name
', ' poster
').text
65 files = data[' video
'][' files
']
68 ' id ': ' %s _ %d ' % (video_id, partnum + 1),
70 title if len(files) == 1 else
71 ' %s part
%d ' % (title, partnum + 1)),
72 ' url
': unescapeHTML(f[' path
'][' #text']),
73 'description' : description
,
74 'thumbnail' : thumbnail
,
75 'duration' : int_or_none ( f
. get ( 'length' , {}). get ( '#text' )),
76 } for partnum
, f
in enumerate ( files
)]