3 from .common
import InfoExtractor
4 from ..utils
import ExtractorError
, int_or_none
, str_to_int
7 class RUTVIE(InfoExtractor
):
11 (?:test)?player\.(?:rutv\.ru|vgtrk\.com)/
13 flash\d+v/container\.swf\?id=|
14 iframe/(?P<type>swf|video|live)/id/|
20 r
'<iframe[^>]+?src=(["\'])(?P
<url
>https?
://(?
:test
)?player\
.(?
:rutv\
.ru|vgtrk\
.com
)/(?
:iframe
/(?
:swf|video|live
)/id|index
/iframe
/cast_id
)/.+?
)\
1',
21 r'<meta
[^
>]+?
property=(["\'])og:video\1[^>]+?content=(["\'])(?P
<url
>https?
://(?
:test
)?player\
.(?
:rutv\
.ru|vgtrk\
.com
)/flash\d
+v
/container\
.swf
\?id=.+?\
2)',
26 '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',
30 'title
': 'Монологи на все времена
',
31 'description
': 'md5
:18d8b5e6a41fb1faa53819471852d5d5
',
36 'skip_download
': True,
40 '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',
44 'title
': 'Чужой в семье Сталина
',
50 'skip_download
': True,
54 'url
': 'http
://player
.rutv
.ru
/iframe
/swf
/id/766888/sid
/hitech
/?acc_video_id
=4000',
58 'title
': 'Вести
.net
: интернет
-гиганты начали перетягивание программных
"одеял"',
59 'description
': 'md5
:65ddd47f9830c4f42ed6475f8730c995
',
64 'skip_download
': True,
68 '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',
72 'title
': 'Прямой эфир
. Жертвы загадочной болезни
: смерть от старости в
17 лет
',
73 'description
': 'md5
:b81c8c55247a4bd996b43ce17395b2d8
',
78 'skip_download
': True,
82 'url
': 'http
://player
.rutv
.ru
/iframe
/live
/id/51499/showZoomBtn
/false
/isPlay
/true
/sid
/sochi2014
',
86 'title
': 'Сочи
-2014. Биатлон
. Индивидуальная гонка
. Мужчины
',
87 'description
': 'md5
:9e0ed5c9d2fa1efbfdfed90c9a6d179c
',
89 'skip
': 'Translation has finished
',
92 'url
': 'http
://player
.rutv
.ru
/iframe
/live
/id/21/showZoomBtn
/false
/isPlay
/true
/',
96 'title
': 're
:^Россия
24. Прямой эфир
[0-9]{4}
-[0-9]{2}
-[0-9]{2}
[0-9]{2}
:[0-9]{2}$
',
101 'skip_download
': True,
105 'url
': 'https
://testplayer
.vgtrk
.com
/iframe
/live
/id/19201/showZoomBtn
/false
/isPlay
/true
/',
106 'only_matching
': True,
110 def _real_extract(self, url):
111 mobj = self._match_valid_url(url)
112 video_id = mobj.group('id')
113 video_path = mobj.group('path
')
115 if re.match(r'flash\d
+v
', video_path):
117 elif video_path.startswith('iframe
'):
118 video_type = mobj.group('type')
119 if video_type == 'swf
':
121 elif video_path.startswith('index
/iframe
/cast_id
'):
124 is_live = video_type == 'live
'
126 json_data = self._download_json(
127 'http
://player
.vgtrk
.com
/iframe
/data
{}/id/{}'.format('live
' if is_live else 'video
', video_id),
128 video_id, 'Downloading JSON
')
130 if json_data['errors
']:
131 raise ExtractorError('{} said
: {}'.format(self.IE_NAME, json_data['errors
']), expected=True)
133 playlist = json_data['data
']['playlist
']
134 medialist = playlist['medialist
']
138 raise ExtractorError('{} said
: {}'.format(self.IE_NAME, media['errors
']), expected=True)
140 view_count = int_or_none(playlist.get('count_views
'))
141 priority_transport = playlist['priority_transport
']
143 thumbnail = media['picture
']
144 width = int_or_none(media['width
'])
145 height = int_or_none(media['height
'])
146 description = media['anons
']
147 title = media['title
']
148 duration = int_or_none(media.get('duration
'))
153 for transport, links in media['sources
'].items():
154 for quality, url in links.items():
155 preference = -1 if priority_transport == transport else -2
156 if transport == 'rtmp
':
157 mobj = re.search(r'^
(?P
<url
>rtmp
://[^
/]+/(?P
<app
>.+))/(?P
<playpath
>.+)$
', url)
161 'url
': mobj.group('url
'),
162 'play_path
': mobj.group('playpath
'),
163 'app
': mobj.group('app
'),
164 'page_url
': 'http
://player
.rutv
.ru
',
165 'player_url
': 'http
://player
.rutv
.ru
/flash3v
/osmf
.swf?i
=22',
168 'vbr
': str_to_int(quality),
170 elif transport == 'm3u8
':
171 fmt, subs = self._extract_m3u8_formats_and_subtitles(
172 url, video_id, 'mp4
', quality=preference, m3u8_id='hls
')
174 self._merge_subtitles(subs, target=subtitles)
181 'width
': int_or_none(quality, default=height, invscale=width, scale=height),
182 'height
': int_or_none(quality, default=height),
183 'format_id
': f'{transport}
-{quality}
',
184 'source_preference
': preference,
191 'description
': description,
192 'thumbnail
': thumbnail,
193 'view_count
': view_count,
194 'duration
': duration,
196 'subtitles
': subtitles,
198 '_format_sort_fields
': ('source
', ),