1 from __future__ import unicode_literals
6 from .common import InfoExtractor
12 class UstreamIE(InfoExtractor):
13 _VALID_URL = r'https?://www\.ustream\.tv/(?P<type>recorded|embed|embed/recorded)/(?P<videoID>\d+)'
16 'url': 'http://www.ustream.tv/recorded/20274954',
17 'md5': '088f151799e8f572f84eb62f17d73e5c',
21 'uploader': 'Young Americans for Liberty',
22 'title': 'Young Americans for Liberty February 7, 2012 2:28 AM',
26 def _real_extract(self, url):
27 m = re.match(self._VALID_URL, url)
28 video_id = m.group('videoID')
30 # some sites use this embed format (see: http://github.com/rg3/youtube-dl/issues/2990)
31 if m.group('type') == 'embed/recorded':
32 video_id = m.group('videoID')
33 desktop_url = 'http://www.ustream.tv/recorded/' + video_id
34 return self.url_result(desktop_url, 'Ustream')
35 if m.group('type') == 'embed':
36 video_id = m.group('videoID')
37 webpage = self._download_webpage(url, video_id)
38 desktop_video_id = self._html_search_regex(
39 r'ContentVideoIds=\["([^"]*?)"\]', webpage, 'desktop_video_id')
40 desktop_url = 'http://www.ustream.tv/recorded/' + desktop_video_id
41 return self.url_result(desktop_url, 'Ustream')
43 params = self._download_json(
44 'http://cdngw.ustream.tv/rgwjson/Viewer.getVideo/' + json.dumps({
46 'videoId': int(video_id),
50 video_url = params['flv']
52 webpage = self._download_webpage(url, video_id)
54 self.report_extraction(video_id)
56 video_title = self._html_search_regex(r'data-title="(?P<title>.+)"',
59 uploader = self._html_search_regex(r'data-content-type="channel".*?>(?P<uploader>.*?)</a>',
60 webpage, 'uploader', fatal=False, flags=re.DOTALL)
62 thumbnail = self._html_search_regex(r'<link rel="image_src" href="(?P<thumb>.*?)"',
63 webpage, 'thumbnail', fatal=False)
71 'thumbnail': thumbnail,
75 class UstreamChannelIE(InfoExtractor):
76 _VALID_URL = r'https?://www\.ustream\.tv/channel/(?P<slug>.+)'
77 IE_NAME = 'ustream:channel'
79 'url': 'http://www.ustream.tv/channel/channeljapan',
83 'playlist_mincount': 17,
86 def _real_extract(self, url):
87 m = re.match(self._VALID_URL, url)
88 display_id = m.group('slug')
89 webpage = self._download_webpage(url, display_id)
90 channel_id = self._html_search_meta('ustream:channel_id', webpage)
92 BASE = 'http://www.ustream.tv'
93 next_url = '/ajax/socialstream/videos/%s/1.json' % channel_id
96 reply = self._download_json(
97 compat_urlparse.urljoin(BASE, next_url), display_id,
98 note='Downloading video information (next: %d)' % (len(video_ids) + 1))
99 video_ids.extend(re.findall(r'data-content-id="(\d.*)"', reply['data']))
100 next_url = reply['nextUrl']
103 self.url_result('http://www.ustream.tv/recorded/' + vid, 'Ustream')
104 for vid in video_ids]
108 'display_id': display_id,