2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class RUTVIE(InfoExtractor):
17 (?:test)?player\.(?:rutv\.ru|vgtrk\.com)/
19 flash\d+v/container\.swf\?id=|
20 iframe/(?P<type>swf|video|live)/id/|
28 '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',
32 'title': 'Монологи на все времена',
33 'description': 'md5:18d8b5e6a41fb1faa53819471852d5d5',
38 'skip_download': True,
42 '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',
46 'title': 'Чужой в семье Сталина',
52 'skip_download': True,
56 'url': 'http://player.rutv.ru/iframe/swf/id/766888/sid/hitech/?acc_video_id=4000',
60 'title': 'Вести.net: интернет-гиганты начали перетягивание программных "одеял"',
61 'description': 'md5:65ddd47f9830c4f42ed6475f8730c995',
66 'skip_download': True,
70 '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',
74 'title': 'Прямой эфир. Жертвы загадочной болезни: смерть от старости в 17 лет',
75 'description': 'md5:b81c8c55247a4bd996b43ce17395b2d8',
80 'skip_download': True,
84 'url': 'http://player.rutv.ru/iframe/live/id/51499/showZoomBtn/false/isPlay/true/sid/sochi2014',
88 'title': 'Сочи-2014. Биатлон. Индивидуальная гонка. Мужчины ',
89 'description': 'md5:9e0ed5c9d2fa1efbfdfed90c9a6d179c',
91 'skip': 'Translation has finished',
94 'url': 'http://player.rutv.ru/iframe/live/id/21/showZoomBtn/false/isPlay/true/',
98 'title': 're:^Россия 24. Прямой эфир [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
103 'skip_download': True,
107 'url': 'https://testplayer.vgtrk.com/iframe/live/id/19201/showZoomBtn/false/isPlay/true/',
108 'only_matching': True,
113 def _extract_url(cls, webpage):
115 r'<iframe[^>]+?src=(["\'])(?P<url>https?://(?:test)?player\.(?:rutv\.ru|vgtrk\.com)/(?:iframe/(?:swf|video|live)/id|index/iframe/cast_id)/.+?)\1', webpage)
117 return mobj.group('url')
120 r'<meta[^>]+?property=(["\'])og:video\1[^>]+?content=(["\'])(?P<url>https?://(?:test)?player\.(?:rutv\.ru|vgtrk\.com)/flash\d+v/container\.swf\?id=.+?\2)',
123 return mobj.group('url')
125 def _real_extract(self, url):
126 mobj = re.match(self._VALID_URL, url)
127 video_id = mobj.group('id')
128 video_path = mobj.group('path')
130 if re.match(r'flash\d+v', video_path):
132 elif video_path.startswith('iframe'):
133 video_type = mobj.group('type')
134 if video_type == 'swf':
136 elif video_path.startswith('index/iframe/cast_id'):
139 is_live = video_type == 'live'
141 json_data = self._download_json(
142 'http://player.rutv.ru/iframe/data%s/id/%s' % ('live' if is_live else 'video', video_id),
143 video_id, 'Downloading JSON')
145 if json_data['errors']:
146 raise ExtractorError('%s said: %s' % (self.IE_NAME, json_data['errors']), expected=True)
148 playlist = json_data['data']['playlist']
149 medialist = playlist['medialist']
153 raise ExtractorError('%s said: %s' % (self.IE_NAME, media['errors']), expected=True)
155 view_count = playlist.get('count_views')
156 priority_transport = playlist['priority_transport']
158 thumbnail = media['picture']
159 width = int_or_none(media['width'])
160 height = int_or_none(media['height'])
161 description = media['anons']
162 title = media['title']
163 duration = int_or_none(media.get('duration'))
167 for transport, links in media['sources'].items():
168 for quality, url in links.items():
169 preference = -1 if priority_transport == transport else -2
170 if transport == 'rtmp':
171 mobj = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+))/(?P<playpath>.+)$', url)
175 'url': mobj.group('url'),
176 'play_path': mobj.group('playpath'),
177 'app': mobj.group('app'),
178 'page_url': 'http://player.rutv.ru',
179 'player_url': 'http://player.rutv.ru/flash3v/osmf.swf?i=22',
183 'preference': preference,
185 elif transport == 'm3u8':
186 formats.extend(self._extract_m3u8_formats(
187 url, video_id, 'mp4', preference=preference, m3u8_id='hls'))
196 'format_id': '%s-%s' % (transport, quality),
200 self._sort_formats(formats)
204 'title': self._live_title(title) if is_live else title,
205 'description': description,
206 'thumbnail': thumbnail,
207 'view_count': view_count,
208 'duration': duration,