1 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class UstreamIE(InfoExtractor):
14 _VALID_URL = r'https?://www\.ustream\.tv/(?P<type>recorded|embed)/(?P<videoID>\d+)'
17 'url': 'http://www.ustream.tv/recorded/20274954',
18 'file': '20274954.flv',
19 '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 if m.group('type') == 'embed':
29 video_id = m.group('videoID')
30 webpage = self._download_webpage(url, video_id)
31 desktop_video_id = self._html_search_regex(r'ContentVideoIds=\["([^"]*?)"\]', webpage, 'desktop_video_id')
32 desktop_url = 'http://www.ustream.tv/recorded/' + desktop_video_id
33 return self.url_result(desktop_url, 'Ustream')
35 video_id = m.group('videoID')
37 video_url = 'http://tcdn.ustream.tv/video/%s' % video_id
38 webpage = self._download_webpage(url, video_id)
40 self.report_extraction(video_id)
42 video_title = self._html_search_regex(r'data-title="(?P<title>.+)"',
45 uploader = self._html_search_regex(r'data-content-type="channel".*?>(?P<uploader>.*?)</a>',
46 webpage, 'uploader', fatal=False, flags=re.DOTALL)
48 thumbnail = self._html_search_regex(r'<link rel="image_src" href="(?P<thumb>.*?)"',
49 webpage, 'thumbnail', fatal=False)
57 'thumbnail': thumbnail,
61 class UstreamChannelIE(InfoExtractor):
62 _VALID_URL = r'https?://www\.ustream\.tv/channel/(?P<slug>.+)'
63 IE_NAME = 'ustream:channel'
65 def _real_extract(self, url):
66 m = re.match(self._VALID_URL, url)
67 slug = m.group('slug')
68 webpage = self._download_webpage(url, slug)
69 channel_id = get_meta_content('ustream:channel_id', webpage)
71 BASE = 'http://www.ustream.tv'
72 next_url = '/ajax/socialstream/videos/%s/1.json' % channel_id
75 reply = json.loads(self._download_webpage(compat_urlparse.urljoin(BASE, next_url), channel_id))
76 video_ids.extend(re.findall(r'data-content-id="(\d.*)"', reply['data']))
77 next_url = reply['nextUrl']
79 urls = ['http://www.ustream.tv/recorded/' + vid for vid in video_ids]
80 url_entries = [self.url_result(eurl, 'Ustream') for eurl in urls]
81 return self.playlist_result(url_entries, channel_id)