]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cspan.py
a4853279bbfc0bce6517a2b1d032ea1eafe07482
   3 from .common 
import InfoExtractor
 
   8 class CSpanIE(InfoExtractor
): 
   9     _VALID_URL 
= r
'http://www.c-spanvideo.org/program/(.*)' 
  11         u
'url': u
'http://www.c-spanvideo.org/program/HolderonV', 
  12         u
'file': u
'315139.flv', 
  13         u
'md5': u
'74a623266956f69e4df0068ab6c80fe4', 
  15             u
"title": u
"Attorney General Eric Holder on Voting Rights Act Decision" 
  17         u
'skip': u
'Requires rtmpdump' 
  20     def _real_extract(self
, url
): 
  21         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  22         prog_name 
= mobj
.group(1) 
  23         webpage 
= self
._download
_webpage
(url
, prog_name
) 
  24         video_id 
= self
._search
_regex
(r
'programid=(.*?)&', webpage
, 'video id') 
  25         data 
= compat_urllib_parse
.urlencode({'programid': video_id
, 
  27         info_url 
= 'http://www.c-spanvideo.org/common/services/flashXml.php?' + data
 
  28         video_info 
= self
._download
_webpage
(info_url
, video_id
, u
'Downloading video info') 
  30         self
.report_extraction(video_id
) 
  32         title 
= self
._html
_search
_regex
(r
'<string name="title">(.*?)</string>', 
  34         description 
= self
._html
_search
_regex
(r
'<meta (?:property="og:|name=")description" content="(.*?)"', 
  35                                               webpage
, 'description', 
  36                                               flags
=re
.MULTILINE|re
.DOTALL
) 
  37         thumbnail 
= self
._html
_search
_regex
(r
'<meta property="og:image" content="(.*?)"', 
  40         url 
= self
._search
_regex
(r
'<string name="URL">(.*?)</string>', 
  41                                  video_info
, 'video url') 
  42         url 
= url
.replace('$(protocol)', 'rtmp').replace('$(port)', '443') 
  43         path 
= self
._search
_regex
(r
'<string name="path">(.*?)</string>', 
  44                             video_info
, 'rtmp play path') 
  46         return {'id': video_id
, 
  51                 'description': description
, 
  52                 'thumbnail': thumbnail
,