- json_data = self._download_json(
- 'http://player.rutv.ru/iframe/%splay/id/%s' % ('live-' if video_type == 'live' else '', video_id),
- video_id, 'Downloading JSON')
-
- if json_data['errors']:
- raise ExtractorError('vesti returned error: %s' % json_data['errors'], expected=True)
-
- playlist = json_data['data']['playlist']
- medialist = playlist['medialist']
- media = medialist[0]
-
- if media['errors']:
- raise ExtractorError('vesti returned error: %s' % media['errors'], expected=True)
-
- view_count = playlist.get('count_views')
- priority_transport = playlist['priority_transport']
-
- thumbnail = media['picture']
- width = media['width']
- height = media['height']
- description = media['anons']
- title = media['title']
- duration = int_or_none(media.get('duration'))
-
- formats = []
-
- for transport, links in media['sources'].items():
- for quality, url in links.items():
- if transport == 'rtmp':
- mobj = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+))/(?P<playpath>.+)$', url)
- if not mobj:
- continue
- fmt = {
- 'url': mobj.group('url'),
- 'play_path': mobj.group('playpath'),
- 'app': mobj.group('app'),
- 'page_url': 'http://player.rutv.ru',
- 'player_url': 'http://player.rutv.ru/flash2v/osmf.swf?i=22',
- 'rtmp_live': True,
- 'ext': 'flv',
- 'vbr': int(quality),
- }
- elif transport == 'm3u8':
- fmt = {
- 'url': url,
- 'ext': 'mp4',
- }
- else:
- fmt = {
- 'url': url
- }
- fmt.update({
- 'width': width,
- 'height': height,
- 'format_id': '%s-%s' % (transport, quality),
- 'preference': -1 if priority_transport == transport else -2,
- })
- formats.append(fmt)
-
- if not formats:
- raise ExtractorError('No media links available for %s' % video_id)
-
- self._sort_formats(formats)