- video_id = m.group('videoID')
-
- video_url = 'http://tcdn.ustream.tv/video/%s' % video_id
- webpage = self._download_webpage(url, video_id)
-
- self.report_extraction(video_id)
+ video_id = m.group('id')
+
+ # some sites use this embed format (see: http://github.com/rg3/youtube-dl/issues/2990)
+ if m.group('type') == 'embed/recorded':
+ video_id = m.group('id')
+ desktop_url = 'http://www.ustream.tv/recorded/' + video_id
+ return self.url_result(desktop_url, 'Ustream')
+ if m.group('type') == 'embed':
+ video_id = m.group('id')
+ webpage = self._download_webpage(url, video_id)
+ desktop_video_id = self._html_search_regex(
+ r'ContentVideoIds=\["([^"]*?)"\]', webpage, 'desktop_video_id')
+ desktop_url = 'http://www.ustream.tv/recorded/' + desktop_video_id
+ return self.url_result(desktop_url, 'Ustream')
+
+ params = self._download_json(
+ 'https://api.ustream.tv/videos/%s.json' % video_id, video_id)
+
+ error = params.get('error')
+ if error:
+ raise ExtractorError(
+ '%s returned error: %s' % (self.IE_NAME, error), expected=True)
+
+ video = params['video']
+
+ title = video['title']
+ filesize = float_or_none(video.get('file_size'))
+
+ formats = [{
+ 'id': video_id,
+ 'url': video_url,
+ 'ext': format_id,
+ 'filesize': filesize,
+ } for format_id, video_url in video['media_urls'].items()]
+ self._sort_formats(formats)