2014-03-28 10:01:08 -06:00
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
from ..utils import (
|
2015-02-10 08:35:34 -07:00
|
|
|
|
int_or_none,
|
2019-11-18 13:40:53 -07:00
|
|
|
|
strip_or_none,
|
|
|
|
|
unescapeHTML,
|
|
|
|
|
xpath_text,
|
2014-03-28 10:01:08 -06:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2015-02-02 12:43:02 -07:00
|
|
|
|
class NTVRuIE(InfoExtractor):
|
2015-02-02 13:48:54 -07:00
|
|
|
|
IE_NAME = 'ntv.ru'
|
2016-08-02 09:56:48 -06:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?ntv\.ru/(?:[^/]+/)*(?P<id>[^/?#&]+)'
|
2014-03-28 10:01:08 -06:00
|
|
|
|
|
2016-08-02 09:56:48 -06:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'http://www.ntv.ru/novosti/863142/',
|
|
|
|
|
'md5': 'ba7ea172a91cb83eb734cad18c10e723',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '746000',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины',
|
|
|
|
|
'description': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины',
|
2017-01-02 05:08:07 -07:00
|
|
|
|
'thumbnail': r're:^http://.*\.jpg',
|
2016-08-02 09:56:48 -06:00
|
|
|
|
'duration': 136,
|
2023-03-03 02:34:56 -07:00
|
|
|
|
'view_count': int,
|
2014-03-28 10:01:08 -06:00
|
|
|
|
},
|
2016-08-02 09:56:48 -06:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.ntv.ru/video/novosti/750370/',
|
|
|
|
|
'md5': 'adecff79691b4d71e25220a191477124',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '750370',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Родные пассажиров пропавшего Boeing не верят в трагический исход',
|
|
|
|
|
'description': 'Родные пассажиров пропавшего Boeing не верят в трагический исход',
|
2017-01-02 05:08:07 -07:00
|
|
|
|
'thumbnail': r're:^http://.*\.jpg',
|
2016-08-02 09:56:48 -06:00
|
|
|
|
'duration': 172,
|
2023-03-03 02:34:56 -07:00
|
|
|
|
'view_count': int,
|
2014-03-28 10:01:08 -06:00
|
|
|
|
},
|
2024-02-24 16:10:37 -07:00
|
|
|
|
'skip': '404 Not Found',
|
2016-08-02 09:56:48 -06:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416',
|
|
|
|
|
'md5': '82dbd49b38e3af1d00df16acbeab260c',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '747480',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': '«Сегодня». 21 марта 2014 года. 16:00',
|
|
|
|
|
'description': '«Сегодня». 21 марта 2014 года. 16:00',
|
2017-01-02 05:08:07 -07:00
|
|
|
|
'thumbnail': r're:^http://.*\.jpg',
|
2016-08-02 09:56:48 -06:00
|
|
|
|
'duration': 1496,
|
2023-03-03 02:34:56 -07:00
|
|
|
|
'view_count': int,
|
2014-03-28 10:01:08 -06:00
|
|
|
|
},
|
2016-08-02 09:56:48 -06:00
|
|
|
|
}, {
|
2019-11-18 13:40:53 -07:00
|
|
|
|
'url': 'https://www.ntv.ru/kino/Koma_film/m70281/o336036/video/',
|
|
|
|
|
'md5': 'e9c7cde24d9d3eaed545911a04e6d4f4',
|
2016-08-02 09:56:48 -06:00
|
|
|
|
'info_dict': {
|
2019-11-18 13:40:53 -07:00
|
|
|
|
'id': '1126480',
|
2016-08-02 09:56:48 -06:00
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Остросюжетный фильм «Кома»',
|
|
|
|
|
'description': 'Остросюжетный фильм «Кома»',
|
2017-01-02 05:08:07 -07:00
|
|
|
|
'thumbnail': r're:^http://.*\.jpg',
|
2016-08-02 09:56:48 -06:00
|
|
|
|
'duration': 5592,
|
2023-03-03 02:34:56 -07:00
|
|
|
|
'view_count': int,
|
2014-03-28 10:01:08 -06:00
|
|
|
|
},
|
2016-08-02 09:56:48 -06:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/',
|
|
|
|
|
'md5': '9320cd0e23f3ea59c330dc744e06ff3b',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '751482',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': '«Дело врачей»: «Деревце жизни»',
|
|
|
|
|
'description': '«Дело врачей»: «Деревце жизни»',
|
2017-01-02 05:08:07 -07:00
|
|
|
|
'thumbnail': r're:^http://.*\.jpg',
|
2016-08-02 09:56:48 -06:00
|
|
|
|
'duration': 2590,
|
2023-03-03 02:34:56 -07:00
|
|
|
|
'view_count': int,
|
2014-03-28 10:01:08 -06:00
|
|
|
|
},
|
2019-11-18 13:40:53 -07:00
|
|
|
|
}, {
|
|
|
|
|
# Schemeless file URL
|
|
|
|
|
'url': 'https://www.ntv.ru/video/1797442',
|
|
|
|
|
'only_matching': True,
|
2016-08-02 09:56:48 -06:00
|
|
|
|
}]
|
2014-03-28 10:01:08 -06:00
|
|
|
|
|
|
|
|
|
_VIDEO_ID_REGEXES = [
|
2024-02-24 16:10:37 -07:00
|
|
|
|
r'<meta property="og:url" content="https?://www\.ntv\.ru/video/(\d+)',
|
|
|
|
|
r'<meta property="og:video:(?:url|iframe)" content="https?://www\.ntv\.ru/embed/(\d+)',
|
2014-03-28 10:01:08 -06:00
|
|
|
|
r'<video embed=[^>]+><id>(\d+)</id>',
|
2014-05-01 13:26:07 -06:00
|
|
|
|
r'<video restriction[^>]+><key>(\d+)</key>',
|
2014-03-28 10:01:08 -06:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2015-02-02 12:43:02 -07:00
|
|
|
|
video_id = self._match_id(url)
|
2014-03-29 02:55:03 -06:00
|
|
|
|
|
2015-02-10 08:35:34 -07:00
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
2014-03-28 10:01:08 -06:00
|
|
|
|
|
2016-08-02 09:56:48 -06:00
|
|
|
|
video_url = self._og_search_property(
|
|
|
|
|
('video', 'video:iframe'), webpage, default=None)
|
|
|
|
|
if video_url:
|
|
|
|
|
video_id = self._search_regex(
|
|
|
|
|
r'https?://(?:www\.)?ntv\.ru/video/(?:embed/)?(\d+)',
|
|
|
|
|
video_url, 'video id', default=None)
|
|
|
|
|
|
|
|
|
|
if not video_id:
|
|
|
|
|
video_id = self._html_search_regex(
|
|
|
|
|
self._VIDEO_ID_REGEXES, webpage, 'video id')
|
2014-03-28 10:01:08 -06:00
|
|
|
|
|
2015-02-10 08:35:34 -07:00
|
|
|
|
player = self._download_xml(
|
2024-06-11 17:09:58 -06:00
|
|
|
|
f'http://www.ntv.ru/vi{video_id}/',
|
2015-02-10 08:35:34 -07:00
|
|
|
|
video_id, 'Downloading video XML')
|
2016-08-02 09:56:48 -06:00
|
|
|
|
|
2019-11-18 13:40:53 -07:00
|
|
|
|
title = strip_or_none(unescapeHTML(xpath_text(player, './data/title', 'title', fatal=True)))
|
2014-03-28 10:01:08 -06:00
|
|
|
|
|
2015-02-10 08:35:34 -07:00
|
|
|
|
video = player.find('./data/video')
|
2014-03-28 10:09:56 -06:00
|
|
|
|
|
2014-03-28 10:01:08 -06:00
|
|
|
|
formats = []
|
|
|
|
|
for format_id in ['', 'hi', 'webm']:
|
2024-06-11 17:09:58 -06:00
|
|
|
|
file_ = xpath_text(video, f'./{format_id}file')
|
2019-11-18 13:40:53 -07:00
|
|
|
|
if not file_:
|
2014-03-28 10:01:08 -06:00
|
|
|
|
continue
|
2019-11-18 13:40:53 -07:00
|
|
|
|
if file_.startswith('//'):
|
|
|
|
|
file_ = self._proto_relative_url(file_)
|
|
|
|
|
elif not file_.startswith('http'):
|
|
|
|
|
file_ = 'http://media.ntv.ru/vod/' + file_
|
2014-03-28 10:01:08 -06:00
|
|
|
|
formats.append({
|
2019-11-18 13:40:53 -07:00
|
|
|
|
'url': file_,
|
2024-06-11 17:09:58 -06:00
|
|
|
|
'filesize': int_or_none(xpath_text(video, f'./{format_id}size')),
|
2014-03-28 10:01:08 -06:00
|
|
|
|
})
|
2023-03-03 02:34:56 -07:00
|
|
|
|
hls_manifest = xpath_text(video, './playback/hls')
|
|
|
|
|
if hls_manifest:
|
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
|
hls_manifest, video_id, m3u8_id='hls', fatal=False))
|
|
|
|
|
dash_manifest = xpath_text(video, './playback/dash')
|
|
|
|
|
if dash_manifest:
|
|
|
|
|
formats.extend(self._extract_mpd_formats(
|
|
|
|
|
dash_manifest, video_id, mpd_id='dash', fatal=False))
|
2014-03-28 10:01:08 -06:00
|
|
|
|
|
|
|
|
|
return {
|
2019-11-18 13:40:53 -07:00
|
|
|
|
'id': xpath_text(video, './id'),
|
2014-03-28 10:01:08 -06:00
|
|
|
|
'title': title,
|
2019-11-18 13:40:53 -07:00
|
|
|
|
'description': strip_or_none(unescapeHTML(xpath_text(player, './data/description'))),
|
|
|
|
|
'thumbnail': xpath_text(video, './splash'),
|
|
|
|
|
'duration': int_or_none(xpath_text(video, './totaltime')),
|
|
|
|
|
'view_count': int_or_none(xpath_text(video, './views')),
|
2014-03-28 10:01:08 -06:00
|
|
|
|
'formats': formats,
|
2014-11-23 12:41:03 -07:00
|
|
|
|
}
|