]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cspan.py
Clarify use of mplayer.
[youtubedl] / youtube_dl / extractor / cspan.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 compat_urllib_parse,
6 )
7
8 class CSpanIE(InfoExtractor):
9 _VALID_URL = r'http://www.c-spanvideo.org/program/(.*)'
10
11 def _real_extract(self, url):
12 mobj = re.match(self._VALID_URL, url)
13 prog_name = mobj.group(1)
14 webpage = self._download_webpage(url, prog_name)
15 video_id = self._search_regex(r'programid=(.*?)&', webpage, 'video id')
16 data = compat_urllib_parse.urlencode({'programid': video_id,
17 'dynamic':'1'})
18 info_url = 'http://www.c-spanvideo.org/common/services/flashXml.php?' + data
19 video_info = self._download_webpage(info_url, video_id, u'Downloading video info')
20
21 self.report_extraction(video_id)
22
23 title = self._html_search_regex(r'<string name="title">(.*?)</string>',
24 video_info, 'title')
25 description = self._html_search_regex(r'<meta (?:property="og:|name=")description" content="(.*?)"',
26 webpage, 'description',
27 flags=re.MULTILINE|re.DOTALL)
28 thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.*?)"',
29 webpage, 'thumbnail')
30
31 url = self._search_regex(r'<string name="URL">(.*?)</string>',
32 video_info, 'video url')
33 url = url.replace('$(protocol)', 'rtmp').replace('$(port)', '443')
34 path = self._search_regex(r'<string name="path">(.*?)</string>',
35 video_info, 'rtmp play path')
36
37 return {'id': video_id,
38 'title': title,
39 'ext': 'flv',
40 'url': url,
41 'play_path': path,
42 'description': description,
43 'thumbnail': thumbnail,
44 }