1
0
Fork 0
mirror of https://github.com/blackjack4494/yt-dlc.git synced 2024-12-23 00:07:49 +00: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): class NTVRuIE(InfoExtractor):
IE_NAME = 'ntv.ru' 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/', 'url': 'http://www.ntv.ru/novosti/863142/',
'md5': 'ba7ea172a91cb83eb734cad18c10e723', 'md5': 'ba7ea172a91cb83eb734cad18c10e723',
'info_dict': { 'info_dict': {
@ -25,8 +24,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg', 'thumbnail': 're:^http://.*\.jpg',
'duration': 136, 'duration': 136,
}, },
}, }, {
{
'url': 'http://www.ntv.ru/video/novosti/750370/', 'url': 'http://www.ntv.ru/video/novosti/750370/',
'md5': 'adecff79691b4d71e25220a191477124', 'md5': 'adecff79691b4d71e25220a191477124',
'info_dict': { 'info_dict': {
@ -37,8 +35,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg', 'thumbnail': 're:^http://.*\.jpg',
'duration': 172, 'duration': 172,
}, },
}, }, {
{
'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416', 'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416',
'md5': '82dbd49b38e3af1d00df16acbeab260c', 'md5': '82dbd49b38e3af1d00df16acbeab260c',
'info_dict': { 'info_dict': {
@ -49,8 +46,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg', 'thumbnail': 're:^http://.*\.jpg',
'duration': 1496, 'duration': 1496,
}, },
}, }, {
{
'url': 'http://www.ntv.ru/kino/Koma_film', 'url': 'http://www.ntv.ru/kino/Koma_film',
'md5': 'f825770930937aa7e5aca0dc0d29319a', 'md5': 'f825770930937aa7e5aca0dc0d29319a',
'info_dict': { 'info_dict': {
@ -61,8 +57,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg', 'thumbnail': 're:^http://.*\.jpg',
'duration': 5592, 'duration': 5592,
}, },
}, }, {
{
'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/', 'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/',
'md5': '9320cd0e23f3ea59c330dc744e06ff3b', 'md5': '9320cd0e23f3ea59c330dc744e06ff3b',
'info_dict': { 'info_dict': {
@ -73,8 +68,7 @@ class NTVRuIE(InfoExtractor):
'thumbnail': 're:^http://.*\.jpg', 'thumbnail': 're:^http://.*\.jpg',
'duration': 2590, 'duration': 2590,
}, },
}, }]
]
_VIDEO_ID_REGEXES = [ _VIDEO_ID_REGEXES = [
r'<meta property="og:url" content="http://www\.ntv\.ru/video/(\d+)', 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) 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( player = self._download_xml(
'http://www.ntv.ru/vi%s/' % video_id, 'http://www.ntv.ru/vi%s/' % video_id,
video_id, 'Downloading video XML') video_id, 'Downloading video XML')
title = clean_html(xpath_text(player, './data/title', 'title', fatal=True)) title = clean_html(xpath_text(player, './data/title', 'title', fatal=True))
description = clean_html(xpath_text(player, './data/description', 'description')) description = clean_html(xpath_text(player, './data/description', 'description'))