1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 10:24:33 +01:00

[ntvru] Fix extraction

This commit is contained in:
Sergey M․ 2016-08-02 22:56:48 +07:00
parent b070564efb
commit 9cb0e65d7e
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -11,10 +11,9 @@ from ..utils import (
class NTVRuIE(InfoExtractor):
IE_NAME = 'ntv.ru'
_VALID_URL = r'https?://(?:www\.)?ntv\.ru/(?P<id>.+)'
_VALID_URL = r'https?://(?:www\.)?ntv\.ru/(?:[^/]+/)*(?P<id>[^/?#&]+)'
_TESTS = [
{
_TESTS = [{
'url': 'http://www.ntv.ru/novosti/863142/',
'md5': 'ba7ea172a91cb83eb734cad18c10e723',
'info_dict': {
@ -25,8 +24,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg',
'duration': 136,
},
},
{
}, {
'url': 'http://www.ntv.ru/video/novosti/750370/',
'md5': 'adecff79691b4d71e25220a191477124',
'info_dict': {
@ -37,8 +35,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg',
'duration': 172,
},
},
{
}, {
'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416',
'md5': '82dbd49b38e3af1d00df16acbeab260c',
'info_dict': {
@ -49,8 +46,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg',
'duration': 1496,
},
},
{
}, {
'url': 'http://www.ntv.ru/kino/Koma_film',
'md5': 'f825770930937aa7e5aca0dc0d29319a',
'info_dict': {
@ -61,8 +57,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg',
'duration': 5592,
},
},
{
}, {
'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/',
'md5': '9320cd0e23f3ea59c330dc744e06ff3b',
'info_dict': {
@ -73,8 +68,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg',
'duration': 2590,
},
},
]
}]
_VIDEO_ID_REGEXES = [
r'<meta property="og:url" content="http://www\.ntv\.ru/video/(\d+)',
@ -87,11 +81,21 @@ class NTVRuIE(InfoExtractor):
webpage = self._download_webpage(url, video_id)
video_id = self._html_search_regex(self._VIDEO_ID_REGEXES, webpage, 'video id')
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')
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'))