]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/cspan.py
1 from __future__
import unicode_literals
5 from . common
import InfoExtractor
12 class CSpanIE ( InfoExtractor
):
13 _VALID_URL
= r
'http://(?:www\.)?c-span\.org/video/\?(?P<id>[0-9a-f]+)'
16 'url' : 'http://www.c-span.org/video/?313572-1/HolderonV' ,
17 'md5' : '8e44ce11f0f725527daccc453f553eb0' ,
21 'title' : 'Attorney General Eric Holder on Voting Rights Act Decision' ,
22 '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.' ,
24 'skip' : 'Regularly fails on travis, for unknown reasons' ,
26 'url' : 'http://www.c-span.org/video/?c4486943/cspan-international-health-care-models' ,
27 # For whatever reason, the served video alternates between
29 #'md5': 'dbb0f047376d457f2ab8b3929cbb2d0c',
33 'title' : 'International Health Care Models' ,
34 'description' : 'md5:7a985a2d595dba00af3d9c9f0783c967' ,
38 def _real_extract ( self
, url
):
39 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
40 page_id
= mobj
. group ( 'id' )
41 webpage
= self
._ download
_ webpage
( url
, page_id
)
42 video_id
= self
._ search
_ regex
( r
'progid=\' ?
([ 0 - 9 ]+) \' ?
> ', webpage, ' video
id ')
44 description = self._html_search_regex(
46 # The full description
47 r' < div
class = \' expandable
\' >(.* ?
)< a href
= \' #\'',
48 # If the description is small enough the other div is not
49 # present, otherwise this is a stripped version
50 r
'<p class=\' initial
\' >(.* ?
)</ p
> '
52 webpage, ' description
', flags=re.DOTALL)
54 info_url = ' http
:// c
- spanvideo
. org
/ videoLibrary
/ assets
/ player
/ ajax
- player
. php?os
= android
& html5
= program
& id = ' + video_id
55 data = self._download_json(info_url, video_id)
57 url = unescapeHTML(data[' video
'][' files
'][0][' path
'][' #text'])
59 doc
= self
._ download
_ xml
( 'http://www.c-span.org/common/services/flashXml.php?programid=' + video_id
+ '&version=2014-01-23' ,
68 def find_string ( node
, s
):
69 return find_xpath_attr ( node
, './/string' , 'name' , s
). text
71 def find_number ( node
, s
):
72 return int ( find_xpath_attr ( node
, './/number' , 'name' , s
). text
)
74 def find_array ( node
, s
):
75 return find_xpath_attr ( node
, './/array' , 'name' , s
)
77 def process_files ( files
, url
, formats
):
79 path
= find_string ( file , 'path' )
80 #duration = find_number(file, './number', 'name', 'length')
81 hd
= find_number ( file , 'hd' )
89 def process_node ( node
, formats
):
90 url
= find_xpath_attr ( node
, './string' , 'name' , 'url' )
92 url
= find_xpath_attr ( node
, './string' , 'name' , 'URL' )
95 url
= url
. text
. replace ( '$(protocol)' , 'rtmp' ). replace ( '$(port)' , '1935' )
96 files
= find_array ( node
, 'files' )
99 process_files ( files
, url
, formats
)
101 process_node ( doc
. find ( './media-link' ), formats
)
103 streams
= find_array ( doc
, 'streams' )
104 if streams
is not None :
105 for stream
in streams
:
106 if find_string ( stream
, 'name' ) != 'vod' :
108 process_node ( stream
, formats
)
112 'title' : find_string ( doc
, 'title' ),
113 'description' : description
,
114 'thumbnail' : find_string ( doc
, 'poster' ),