|
@ -3,7 +3,9 @@ from __future__ import unicode_literals |
|
|
|
|
|
|
|
|
from .common import InfoExtractor |
|
|
from .common import InfoExtractor |
|
|
from ..utils import ( |
|
|
from ..utils import ( |
|
|
unescapeHTML |
|
|
|
|
|
|
|
|
clean_html, |
|
|
|
|
|
xpath_text, |
|
|
|
|
|
int_or_none, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -14,73 +16,63 @@ class NTVRuIE(InfoExtractor): |
|
|
_TESTS = [ |
|
|
_TESTS = [ |
|
|
{ |
|
|
{ |
|
|
'url': 'http://www.ntv.ru/novosti/863142/', |
|
|
'url': 'http://www.ntv.ru/novosti/863142/', |
|
|
|
|
|
'md5': 'ba7ea172a91cb83eb734cad18c10e723', |
|
|
'info_dict': { |
|
|
'info_dict': { |
|
|
'id': '746000', |
|
|
'id': '746000', |
|
|
'ext': 'flv', |
|
|
|
|
|
|
|
|
'ext': 'mp4', |
|
|
'title': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', |
|
|
'title': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', |
|
|
'description': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', |
|
|
'description': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', |
|
|
|
|
|
'thumbnail': 're:^http://.*\.jpg', |
|
|
'duration': 136, |
|
|
'duration': 136, |
|
|
}, |
|
|
}, |
|
|
'params': { |
|
|
|
|
|
# rtmp download |
|
|
|
|
|
'skip_download': True, |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
'url': 'http://www.ntv.ru/video/novosti/750370/', |
|
|
'url': 'http://www.ntv.ru/video/novosti/750370/', |
|
|
|
|
|
'md5': 'adecff79691b4d71e25220a191477124', |
|
|
'info_dict': { |
|
|
'info_dict': { |
|
|
'id': '750370', |
|
|
'id': '750370', |
|
|
'ext': 'flv', |
|
|
|
|
|
|
|
|
'ext': 'mp4', |
|
|
'title': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', |
|
|
'title': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', |
|
|
'description': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', |
|
|
'description': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', |
|
|
|
|
|
'thumbnail': 're:^http://.*\.jpg', |
|
|
'duration': 172, |
|
|
'duration': 172, |
|
|
}, |
|
|
}, |
|
|
'params': { |
|
|
|
|
|
# rtmp download |
|
|
|
|
|
'skip_download': True, |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416', |
|
|
'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416', |
|
|
|
|
|
'md5': '82dbd49b38e3af1d00df16acbeab260c', |
|
|
'info_dict': { |
|
|
'info_dict': { |
|
|
'id': '747480', |
|
|
'id': '747480', |
|
|
'ext': 'flv', |
|
|
|
|
|
'title': '«Сегодня». 21 марта 2014 года. 16:00 ', |
|
|
|
|
|
'description': '«Сегодня». 21 марта 2014 года. 16:00 ', |
|
|
|
|
|
|
|
|
'ext': 'mp4', |
|
|
|
|
|
'title': '«Сегодня». 21 марта 2014 года. 16:00', |
|
|
|
|
|
'description': '«Сегодня». 21 марта 2014 года. 16:00', |
|
|
|
|
|
'thumbnail': 're:^http://.*\.jpg', |
|
|
'duration': 1496, |
|
|
'duration': 1496, |
|
|
}, |
|
|
}, |
|
|
'params': { |
|
|
|
|
|
# rtmp download |
|
|
|
|
|
'skip_download': True, |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
'url': 'http://www.ntv.ru/kino/Koma_film', |
|
|
'url': 'http://www.ntv.ru/kino/Koma_film', |
|
|
|
|
|
'md5': 'f825770930937aa7e5aca0dc0d29319a', |
|
|
'info_dict': { |
|
|
'info_dict': { |
|
|
'id': '758100', |
|
|
|
|
|
'ext': 'flv', |
|
|
|
|
|
|
|
|
'id': '1007609', |
|
|
|
|
|
'ext': 'mp4', |
|
|
'title': 'Остросюжетный фильм «Кома»', |
|
|
'title': 'Остросюжетный фильм «Кома»', |
|
|
'description': 'Остросюжетный фильм «Кома»', |
|
|
'description': 'Остросюжетный фильм «Кома»', |
|
|
|
|
|
'thumbnail': 're:^http://.*\.jpg', |
|
|
'duration': 5592, |
|
|
'duration': 5592, |
|
|
}, |
|
|
}, |
|
|
'params': { |
|
|
|
|
|
# rtmp download |
|
|
|
|
|
'skip_download': True, |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/', |
|
|
'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/', |
|
|
|
|
|
'md5': '9320cd0e23f3ea59c330dc744e06ff3b', |
|
|
'info_dict': { |
|
|
'info_dict': { |
|
|
'id': '751482', |
|
|
'id': '751482', |
|
|
'ext': 'flv', |
|
|
|
|
|
|
|
|
'ext': 'mp4', |
|
|
'title': '«Дело врачей»: «Деревце жизни»', |
|
|
'title': '«Дело врачей»: «Деревце жизни»', |
|
|
'description': '«Дело врачей»: «Деревце жизни»', |
|
|
'description': '«Дело врачей»: «Деревце жизни»', |
|
|
|
|
|
'thumbnail': 're:^http://.*\.jpg', |
|
|
'duration': 2590, |
|
|
'duration': 2590, |
|
|
}, |
|
|
}, |
|
|
'params': { |
|
|
|
|
|
# rtmp download |
|
|
|
|
|
'skip_download': True, |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
}, |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
@ -92,45 +84,36 @@ class NTVRuIE(InfoExtractor): |
|
|
|
|
|
|
|
|
def _real_extract(self, url): |
|
|
def _real_extract(self, url): |
|
|
video_id = self._match_id(url) |
|
|
video_id = self._match_id(url) |
|
|
page = self._download_webpage(url, video_id) |
|
|
|
|
|
|
|
|
|
|
|
video_id = self._html_search_regex(self._VIDEO_ID_REGEXES, page, 'video id') |
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, video_id) |
|
|
|
|
|
|
|
|
player = self._download_xml('http://www.ntv.ru/vi%s/' % video_id, video_id, 'Downloading video XML') |
|
|
|
|
|
title = unescapeHTML(player.find('./data/title').text) |
|
|
|
|
|
description = unescapeHTML(player.find('./data/description').text) |
|
|
|
|
|
|
|
|
video_id = self._html_search_regex(self._VIDEO_ID_REGEXES, webpage, 'video id') |
|
|
|
|
|
|
|
|
video = player.find('./data/video') |
|
|
|
|
|
video_id = video.find('./id').text |
|
|
|
|
|
thumbnail = video.find('./splash').text |
|
|
|
|
|
duration = int(video.find('./totaltime').text) |
|
|
|
|
|
view_count = int(video.find('./views').text) |
|
|
|
|
|
puid22 = video.find('./puid22').text |
|
|
|
|
|
|
|
|
player = self._download_xml( |
|
|
|
|
|
'http://www.ntv.ru/vi%s/' % video_id, |
|
|
|
|
|
video_id, 'Downloading video XML') |
|
|
|
|
|
title = clean_html(xpath_text(player, './data/title', 'title', fatal=True)) |
|
|
|
|
|
description = clean_html(xpath_text(player, './data/description', 'description')) |
|
|
|
|
|
|
|
|
apps = { |
|
|
|
|
|
'4': 'video1', |
|
|
|
|
|
'7': 'video2', |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
video = player.find('./data/video') |
|
|
|
|
|
video_id = xpath_text(video, './id', 'video id') |
|
|
|
|
|
thumbnail = xpath_text(video, './splash', 'thumbnail') |
|
|
|
|
|
duration = int_or_none(xpath_text(video, './totaltime', 'duration')) |
|
|
|
|
|
view_count = int_or_none(xpath_text(video, './views', 'view count')) |
|
|
|
|
|
|
|
|
app = apps.get(puid22, apps['4']) |
|
|
|
|
|
|
|
|
token = self._download_webpage( |
|
|
|
|
|
'http://stat.ntv.ru/services/access/token', |
|
|
|
|
|
video_id, 'Downloading access token') |
|
|
|
|
|
|
|
|
formats = [] |
|
|
formats = [] |
|
|
for format_id in ['', 'hi', 'webm']: |
|
|
for format_id in ['', 'hi', 'webm']: |
|
|
file = video.find('./%sfile' % format_id) |
|
|
|
|
|
if file is None: |
|
|
|
|
|
|
|
|
file_ = video.find('./%sfile' % format_id) |
|
|
|
|
|
if file_ is None: |
|
|
continue |
|
|
continue |
|
|
size = video.find('./%ssize' % format_id) |
|
|
size = video.find('./%ssize' % format_id) |
|
|
formats.append({ |
|
|
formats.append({ |
|
|
'url': 'rtmp://media.ntv.ru/%s' % app, |
|
|
|
|
|
'app': app, |
|
|
|
|
|
'play_path': file.text, |
|
|
|
|
|
'rtmp_conn': 'B:1', |
|
|
|
|
|
'player_url': 'http://www.ntv.ru/swf/vps1.swf?update=20131128', |
|
|
|
|
|
'page_url': 'http://www.ntv.ru', |
|
|
|
|
|
'flash_version': 'LNX 11,2,202,341', |
|
|
|
|
|
'rtmp_live': True, |
|
|
|
|
|
'ext': 'flv', |
|
|
|
|
|
'filesize': int(size.text), |
|
|
|
|
|
|
|
|
'url': 'http://media2.ntv.ru/vod/%s&tok=%s' % (file_.text, token), |
|
|
|
|
|
'filesize': int_or_none(size.text if size is not None else None), |
|
|
}) |
|
|
}) |
|
|
self._sort_formats(formats) |
|
|
self._sort_formats(formats) |
|
|
|
|
|
|
|
|