2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class RUTVIE(InfoExtractor):
15 _VALID_URL = r'https?://player\.(?:rutv\.ru|vgtrk\.com)/(?:flash2v/container\.swf\?id=|iframe/(?P<type>swf|video|live)/id/)(?P<id>\d+)'
19 'url': 'http://player.rutv.ru/flash2v/container.swf?id=774471&sid=kultura&fbv=true&isPlay=true&ssl=false&i=560&acc_video_id=episode_id/972347/video_id/978186/brand_id/31724',
23 'title': 'Монологи на все времена',
24 'description': 'md5:18d8b5e6a41fb1faa53819471852d5d5',
29 'skip_download': True,
33 'url': 'https://player.vgtrk.com/flash2v/container.swf?id=774016&sid=russiatv&fbv=true&isPlay=true&ssl=false&i=560&acc_video_id=episode_id/972098/video_id/977760/brand_id/57638',
37 'title': 'Чужой в семье Сталина',
43 'skip_download': True,
47 'url': 'http://player.rutv.ru/iframe/swf/id/766888/sid/hitech/?acc_video_id=4000',
51 'title': 'Вести.net: интернет-гиганты начали перетягивание программных "одеял"',
52 'description': 'md5:65ddd47f9830c4f42ed6475f8730c995',
57 'skip_download': True,
61 'url': 'http://player.rutv.ru/iframe/video/id/771852/start_zoom/true/showZoomBtn/false/sid/russiatv/?acc_video_id=episode_id/970443/video_id/975648/brand_id/5169',
65 'title': 'Прямой эфир. Жертвы загадочной болезни: смерть от старости в 17 лет',
66 'description': 'md5:b81c8c55247a4bd996b43ce17395b2d8',
71 'skip_download': True,
75 'url': 'http://player.rutv.ru/iframe/live/id/51499/showZoomBtn/false/isPlay/true/sid/sochi2014',
79 'title': 'Сочи-2014. Биатлон. Индивидуальная гонка. Мужчины ',
80 'description': 'md5:9e0ed5c9d2fa1efbfdfed90c9a6d179c',
84 'skip_download': True,
86 'skip': 'Translation has finished',
91 def _extract_url(cls, webpage):
93 r'<iframe[^>]+?src=(["\'])(?P<url>https?://player\.rutv\.ru/iframe/(?:swf|video|live)/id/.+?)\1', webpage)
95 return mobj.group('url')
98 r'<meta[^>]+?property=(["\'])og:video\1[^>]+?content=(["\'])(?P<url>http://player\.(?:rutv\.ru|vgtrk\.com)/flash2v/container\.swf\?id=.+?\2)',
101 return mobj.group('url')
103 def _real_extract(self, url):
104 mobj = re.match(self._VALID_URL, url)
105 video_id = mobj.group('id')
106 video_type = mobj.group('type')
108 if not video_type or video_type == 'swf':
111 json_data = self._download_json(
112 'http://player.rutv.ru/iframe/%splay/id/%s' % ('live-' if video_type == 'live' else '', video_id),
113 video_id, 'Downloading JSON')
115 if json_data['errors']:
116 raise ExtractorError('%s said: %s' % (self.IE_NAME, json_data['errors']), expected=True)
118 playlist = json_data['data']['playlist']
119 medialist = playlist['medialist']
123 raise ExtractorError('%s said: %s' % (self.IE_NAME, media['errors']), expected=True)
125 view_count = playlist.get('count_views')
126 priority_transport = playlist['priority_transport']
128 thumbnail = media['picture']
129 width = int_or_none(media['width'])
130 height = int_or_none(media['height'])
131 description = media['anons']
132 title = media['title']
133 duration = int_or_none(media.get('duration'))
137 for transport, links in media['sources'].items():
138 for quality, url in links.items():
139 if transport == 'rtmp':
140 mobj = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+))/(?P<playpath>.+)$', url)
144 'url': mobj.group('url'),
145 'play_path': mobj.group('playpath'),
146 'app': mobj.group('app'),
147 'page_url': 'http://player.rutv.ru',
148 'player_url': 'http://player.rutv.ru/flash2v/osmf.swf?i=22',
153 elif transport == 'm3u8':
165 'format_id': '%s-%s' % (transport, quality),
166 'preference': -1 if priority_transport == transport else -2,
171 raise ExtractorError('No media links available for %s' % video_id)
173 self._sort_formats(formats)
178 'description': description,
179 'thumbnail': thumbnail,
180 'view_count': view_count,
181 'duration': duration,