2014-02-13 09:22:23 -07:00
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2024-05-26 13:27:21 -06:00
|
|
|
from ..utils import ExtractorError, int_or_none, str_to_int
|
2014-02-13 09:22:23 -07:00
|
|
|
|
|
|
|
|
2014-03-16 12:59:40 -06:00
|
|
|
class RUTVIE(InfoExtractor):
|
|
|
|
IE_DESC = 'RUTV.RU'
|
2014-05-09 13:23:24 -06:00
|
|
|
_VALID_URL = r'''(?x)
|
2017-06-11 08:36:19 -06:00
|
|
|
https?://
|
|
|
|
(?:test)?player\.(?:rutv\.ru|vgtrk\.com)/
|
|
|
|
(?P<path>
|
|
|
|
flash\d+v/container\.swf\?id=|
|
|
|
|
iframe/(?P<type>swf|video|live)/id/|
|
|
|
|
index/iframe/cast_id/
|
|
|
|
)
|
|
|
|
(?P<id>\d+)
|
|
|
|
'''
|
2022-07-31 19:23:25 -06:00
|
|
|
_EMBED_URLS = [
|
|
|
|
r'<iframe[^>]+?src=(["\'])(?P<url>https?://(?:test)?player\.(?:rutv\.ru|vgtrk\.com)/(?:iframe/(?:swf|video|live)/id|index/iframe/cast_id)/.+?)\1',
|
|
|
|
r'<meta[^>]+?property=(["\'])og:video\1[^>]+?content=(["\'])(?P<url>https?://(?:test)?player\.(?:rutv\.ru|vgtrk\.com)/flash\d+v/container\.swf\?id=.+?\2)',
|
|
|
|
]
|
2014-02-13 09:22:23 -07:00
|
|
|
|
|
|
|
_TESTS = [
|
|
|
|
{
|
2014-03-16 12:59:40 -06:00
|
|
|
'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',
|
2014-02-13 09:22:23 -07:00
|
|
|
'info_dict': {
|
2014-03-16 12:59:40 -06:00
|
|
|
'id': '774471',
|
2014-03-06 12:27:39 -07:00
|
|
|
'ext': 'mp4',
|
2014-03-16 12:59:40 -06:00
|
|
|
'title': 'Монологи на все времена',
|
|
|
|
'description': 'md5:18d8b5e6a41fb1faa53819471852d5d5',
|
|
|
|
'duration': 2906,
|
2014-03-06 12:27:39 -07:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
# m3u8 download
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
},
|
2014-02-13 09:22:23 -07:00
|
|
|
{
|
2014-03-16 12:59:40 -06:00
|
|
|
'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',
|
2014-02-13 09:22:23 -07:00
|
|
|
'info_dict': {
|
2014-03-16 12:59:40 -06:00
|
|
|
'id': '774016',
|
2014-02-13 09:22:23 -07:00
|
|
|
'ext': 'mp4',
|
2014-03-16 12:59:40 -06:00
|
|
|
'title': 'Чужой в семье Сталина',
|
|
|
|
'description': '',
|
|
|
|
'duration': 2539,
|
2014-02-13 09:22:23 -07:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
# m3u8 download
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
},
|
2014-03-06 12:27:39 -07:00
|
|
|
{
|
2014-03-16 12:59:40 -06:00
|
|
|
'url': 'http://player.rutv.ru/iframe/swf/id/766888/sid/hitech/?acc_video_id=4000',
|
2014-03-06 12:27:39 -07:00
|
|
|
'info_dict': {
|
|
|
|
'id': '766888',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Вести.net: интернет-гиганты начали перетягивание программных "одеял"',
|
|
|
|
'description': 'md5:65ddd47f9830c4f42ed6475f8730c995',
|
|
|
|
'duration': 279,
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
# m3u8 download
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
},
|
2014-03-10 05:52:00 -06:00
|
|
|
{
|
2014-03-16 12:59:40 -06:00
|
|
|
'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',
|
2014-03-10 05:52:00 -06:00
|
|
|
'info_dict': {
|
2014-03-16 12:59:40 -06:00
|
|
|
'id': '771852',
|
2014-03-10 05:52:00 -06:00
|
|
|
'ext': 'mp4',
|
2014-03-16 12:59:40 -06:00
|
|
|
'title': 'Прямой эфир. Жертвы загадочной болезни: смерть от старости в 17 лет',
|
|
|
|
'description': 'md5:b81c8c55247a4bd996b43ce17395b2d8',
|
|
|
|
'duration': 3096,
|
2014-03-10 05:52:00 -06:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
# m3u8 download
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2014-03-16 12:59:40 -06:00
|
|
|
'url': 'http://player.rutv.ru/iframe/live/id/51499/showZoomBtn/false/isPlay/true/sid/sochi2014',
|
2014-03-10 05:52:00 -06:00
|
|
|
'info_dict': {
|
|
|
|
'id': '51499',
|
|
|
|
'ext': 'flv',
|
|
|
|
'title': 'Сочи-2014. Биатлон. Индивидуальная гонка. Мужчины ',
|
|
|
|
'description': 'md5:9e0ed5c9d2fa1efbfdfed90c9a6d179c',
|
|
|
|
},
|
2015-05-02 22:00:34 -06:00
|
|
|
'skip': 'Translation has finished',
|
|
|
|
},
|
|
|
|
{
|
2015-05-04 09:23:26 -06:00
|
|
|
'url': 'http://player.rutv.ru/iframe/live/id/21/showZoomBtn/false/isPlay/true/',
|
2015-05-02 22:00:34 -06:00
|
|
|
'info_dict': {
|
|
|
|
'id': '21',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 're:^Россия 24. Прямой эфир [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
|
|
|
|
'is_live': True,
|
|
|
|
},
|
2014-03-10 05:52:00 -06:00
|
|
|
'params': {
|
2015-05-02 22:00:34 -06:00
|
|
|
# m3u8 download
|
2014-03-10 05:52:00 -06:00
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
},
|
2017-06-11 08:36:19 -06:00
|
|
|
{
|
|
|
|
'url': 'https://testplayer.vgtrk.com/iframe/live/id/19201/showZoomBtn/false/isPlay/true/',
|
|
|
|
'only_matching': True,
|
|
|
|
},
|
2014-02-13 09:22:23 -07:00
|
|
|
]
|
|
|
|
|
2014-03-16 12:59:40 -06:00
|
|
|
def _real_extract(self, url):
|
2021-08-18 19:41:24 -06:00
|
|
|
mobj = self._match_valid_url(url)
|
2014-03-16 12:59:40 -06:00
|
|
|
video_id = mobj.group('id')
|
2014-05-09 13:23:24 -06:00
|
|
|
video_path = mobj.group('path')
|
2014-02-13 09:22:23 -07:00
|
|
|
|
2016-03-21 09:46:49 -06:00
|
|
|
if re.match(r'flash\d+v', video_path):
|
2014-03-16 12:59:40 -06:00
|
|
|
video_type = 'video'
|
2014-05-09 13:23:24 -06:00
|
|
|
elif video_path.startswith('iframe'):
|
|
|
|
video_type = mobj.group('type')
|
|
|
|
if video_type == 'swf':
|
|
|
|
video_type = 'video'
|
|
|
|
elif video_path.startswith('index/iframe/cast_id'):
|
|
|
|
video_type = 'live'
|
2014-02-13 09:22:23 -07:00
|
|
|
|
2015-05-04 09:29:32 -06:00
|
|
|
is_live = video_type == 'live'
|
|
|
|
|
2014-02-13 09:22:23 -07:00
|
|
|
json_data = self._download_json(
|
2024-06-11 17:09:58 -06:00
|
|
|
'http://player.vgtrk.com/iframe/data{}/id/{}'.format('live' if is_live else 'video', video_id),
|
2014-02-13 09:22:23 -07:00
|
|
|
video_id, 'Downloading JSON')
|
|
|
|
|
|
|
|
if json_data['errors']:
|
2024-06-11 17:09:58 -06:00
|
|
|
raise ExtractorError('{} said: {}'.format(self.IE_NAME, json_data['errors']), expected=True)
|
2014-02-13 09:22:23 -07:00
|
|
|
|
|
|
|
playlist = json_data['data']['playlist']
|
|
|
|
medialist = playlist['medialist']
|
|
|
|
media = medialist[0]
|
|
|
|
|
|
|
|
if media['errors']:
|
2024-06-11 17:09:58 -06:00
|
|
|
raise ExtractorError('{} said: {}'.format(self.IE_NAME, media['errors']), expected=True)
|
2014-02-13 09:22:23 -07:00
|
|
|
|
2022-09-24 03:30:58 -06:00
|
|
|
view_count = int_or_none(playlist.get('count_views'))
|
2014-02-13 09:22:23 -07:00
|
|
|
priority_transport = playlist['priority_transport']
|
|
|
|
|
|
|
|
thumbnail = media['picture']
|
2014-03-04 07:40:35 -07:00
|
|
|
width = int_or_none(media['width'])
|
|
|
|
height = int_or_none(media['height'])
|
2014-02-13 09:22:23 -07:00
|
|
|
description = media['anons']
|
|
|
|
title = media['title']
|
|
|
|
duration = int_or_none(media.get('duration'))
|
|
|
|
|
|
|
|
formats = []
|
2022-09-24 03:30:58 -06:00
|
|
|
subtitles = {}
|
2014-02-13 09:22:23 -07:00
|
|
|
|
|
|
|
for transport, links in media['sources'].items():
|
|
|
|
for quality, url in links.items():
|
2015-05-04 09:29:32 -06:00
|
|
|
preference = -1 if priority_transport == transport else -2
|
2014-02-13 09:22:23 -07:00
|
|
|
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',
|
2016-03-21 09:46:49 -06:00
|
|
|
'player_url': 'http://player.rutv.ru/flash3v/osmf.swf?i=22',
|
2014-02-13 09:22:23 -07:00
|
|
|
'rtmp_live': True,
|
|
|
|
'ext': 'flv',
|
2022-03-04 10:01:04 -07:00
|
|
|
'vbr': str_to_int(quality),
|
2014-02-13 09:22:23 -07:00
|
|
|
}
|
|
|
|
elif transport == 'm3u8':
|
2022-09-24 03:30:58 -06:00
|
|
|
fmt, subs = self._extract_m3u8_formats_and_subtitles(
|
|
|
|
url, video_id, 'mp4', quality=preference, m3u8_id='hls')
|
|
|
|
formats.extend(fmt)
|
|
|
|
self._merge_subtitles(subs, target=subtitles)
|
2015-02-01 10:48:23 -07:00
|
|
|
continue
|
2014-02-13 09:22:23 -07:00
|
|
|
else:
|
|
|
|
fmt = {
|
2024-06-11 17:09:58 -06:00
|
|
|
'url': url,
|
2014-02-13 09:22:23 -07:00
|
|
|
}
|
|
|
|
fmt.update({
|
2022-03-17 08:11:36 -06:00
|
|
|
'width': int_or_none(quality, default=height, invscale=width, scale=height),
|
|
|
|
'height': int_or_none(quality, default=height),
|
2024-06-11 17:09:58 -06:00
|
|
|
'format_id': f'{transport}-{quality}',
|
2022-03-17 08:11:36 -06:00
|
|
|
'source_preference': preference,
|
2014-02-13 09:22:23 -07:00
|
|
|
})
|
|
|
|
formats.append(fmt)
|
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
2021-12-15 09:00:46 -07:00
|
|
|
'title': title,
|
2014-02-13 09:22:23 -07:00
|
|
|
'description': description,
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
'view_count': view_count,
|
|
|
|
'duration': duration,
|
|
|
|
'formats': formats,
|
2022-09-24 03:30:58 -06:00
|
|
|
'subtitles': subtitles,
|
2015-05-02 21:56:03 -06:00
|
|
|
'is_live': is_live,
|
2022-11-16 22:10:03 -07:00
|
|
|
'_format_sort_fields': ('source', ),
|
2014-11-23 12:41:03 -07:00
|
|
|
}
|