2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class RUTVIE(InfoExtractor):
16 https?://player\.(?:rutv\.ru|vgtrk\.com)/
17 (?P<path>flash2v/container\.swf\?id=
18 |iframe/(?P<type>swf|video|live)/id/
19 |index/iframe/cast_id/)
24 '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',
28 'title': 'Монологи на все времена',
29 'description': 'md5:18d8b5e6a41fb1faa53819471852d5d5',
34 'skip_download': True,
38 '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',
42 'title': 'Чужой в семье Сталина',
48 'skip_download': True,
52 'url': 'http://player.rutv.ru/iframe/swf/id/766888/sid/hitech/?acc_video_id=4000',
56 'title': 'Вести.net: интернет-гиганты начали перетягивание программных "одеял"',
57 'description': 'md5:65ddd47f9830c4f42ed6475f8730c995',
62 'skip_download': True,
66 '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',
70 'title': 'Прямой эфир. Жертвы загадочной болезни: смерть от старости в 17 лет',
71 'description': 'md5:b81c8c55247a4bd996b43ce17395b2d8',
76 'skip_download': True,
80 'url': 'http://player.rutv.ru/iframe/live/id/51499/showZoomBtn/false/isPlay/true/sid/sochi2014',
84 'title': 'Сочи-2014. Биатлон. Индивидуальная гонка. Мужчины ',
85 'description': 'md5:9e0ed5c9d2fa1efbfdfed90c9a6d179c',
89 'skip_download': True,
91 'skip': 'Translation has finished',
96 def _extract_url(cls, webpage):
98 r'<iframe[^>]+?src=(["\'])(?P<url>https?://player\.rutv\.ru/(?:iframe/(?:swf|video|live)/id|index/iframe/cast_id)/.+?)\1', webpage)
100 return mobj.group('url')
103 r'<meta[^>]+?property=(["\'])og:video\1[^>]+?content=(["\'])(?P<url>https?://player\.(?:rutv\.ru|vgtrk\.com)/flash2v/container\.swf\?id=.+?\2)',
106 return mobj.group('url')
108 def _real_extract(self, url):
109 mobj = re.match(self._VALID_URL, url)
110 video_id = mobj.group('id')
111 video_path = mobj.group('path')
113 if video_path.startswith('flash2v'):
115 elif video_path.startswith('iframe'):
116 video_type = mobj.group('type')
117 if video_type == 'swf':
119 elif video_path.startswith('index/iframe/cast_id'):
122 json_data = self._download_json(
123 'http://player.rutv.ru/iframe/%splay/id/%s' % ('live-' if video_type == 'live' else '', video_id),
124 video_id, 'Downloading JSON')
126 if json_data['errors']:
127 raise ExtractorError('%s said: %s' % (self.IE_NAME, json_data['errors']), expected=True)
129 playlist = json_data['data']['playlist']
130 medialist = playlist['medialist']
134 raise ExtractorError('%s said: %s' % (self.IE_NAME, media['errors']), expected=True)
136 view_count = playlist.get('count_views')
137 priority_transport = playlist['priority_transport']
139 thumbnail = media['picture']
140 width = int_or_none(media['width'])
141 height = int_or_none(media['height'])
142 description = media['anons']
143 title = media['title']
144 duration = int_or_none(media.get('duration'))
148 for transport, links in media['sources'].items():
149 for quality, url in links.items():
150 if transport == 'rtmp':
151 mobj = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+))/(?P<playpath>.+)$', url)
155 'url': mobj.group('url'),
156 'play_path': mobj.group('playpath'),
157 'app': mobj.group('app'),
158 'page_url': 'http://player.rutv.ru',
159 'player_url': 'http://player.rutv.ru/flash2v/osmf.swf?i=22',
164 elif transport == 'm3u8':
165 formats.extend(self._extract_m3u8_formats(url, video_id, 'mp4'))
174 'format_id': '%s-%s' % (transport, quality),
175 'preference': -1 if priority_transport == transport else -2,
180 raise ExtractorError('No media links available for %s' % video_id)
182 self._sort_formats(formats)
187 'description': description,
188 'thumbnail': thumbnail,
189 'view_count': view_count,
190 'duration': duration,