Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Asadullah Ahmad 2015-07-17 01:12:47 +05:00
commit 8126ae97c5
4 changed files with 157 additions and 27 deletions

View File

@ -389,7 +389,8 @@ from .npo import (
NPOLiveIE, NPOLiveIE,
NPORadioIE, NPORadioIE,
NPORadioFragmentIE, NPORadioFragmentIE,
TegenlichtVproIE, VPROIE,
WNLIE
) )
from .nrk import ( from .nrk import (
NRKIE, NRKIE,

View File

@ -27,7 +27,9 @@ from ..utils import (
bug_reports_message, bug_reports_message,
clean_html, clean_html,
compiled_regex_type, compiled_regex_type,
determine_ext,
ExtractorError, ExtractorError,
fix_xml_ampersands,
float_or_none, float_or_none,
int_or_none, int_or_none,
RegexNotFoundError, RegexNotFoundError,
@ -837,7 +839,10 @@ class InfoExtractor(object):
def _extract_f4m_formats(self, manifest_url, video_id, preference=None, f4m_id=None): def _extract_f4m_formats(self, manifest_url, video_id, preference=None, f4m_id=None):
manifest = self._download_xml( manifest = self._download_xml(
manifest_url, video_id, 'Downloading f4m manifest', manifest_url, video_id, 'Downloading f4m manifest',
'Unable to download f4m manifest') 'Unable to download f4m manifest',
# Some manifests may be malformed, e.g. prosiebensat1 generated manifests
# (see https://github.com/rg3/youtube-dl/issues/6215#issuecomment-121704244)
transform_source=lambda s: fix_xml_ampersands(s).strip())
formats = [] formats = []
manifest_version = '1.0' manifest_version = '1.0'
@ -847,8 +852,19 @@ class InfoExtractor(object):
media_nodes = manifest.findall('{http://ns.adobe.com/f4m/2.0}media') media_nodes = manifest.findall('{http://ns.adobe.com/f4m/2.0}media')
for i, media_el in enumerate(media_nodes): for i, media_el in enumerate(media_nodes):
if manifest_version == '2.0': if manifest_version == '2.0':
manifest_url = ('/'.join(manifest_url.split('/')[:-1]) + '/' + media_url = media_el.attrib.get('href') or media_el.attrib.get('url')
(media_el.attrib.get('href') or media_el.attrib.get('url'))) if not media_url:
continue
manifest_url = (
media_url if media_url.startswith('http://') or media_url.startswith('https://')
else ('/'.join(manifest_url.split('/')[:-1]) + '/' + media_url))
# If media_url is itself a f4m manifest do the recursive extraction
# since bitrates in parent manifest (this one) and media_url manifest
# may differ leading to inability to resolve the format by requested
# bitrate in f4m downloader
if determine_ext(manifest_url) == 'f4m':
formats.extend(self._extract_f4m_formats(manifest_url, video_id, preference, f4m_id))
continue
tbr = int_or_none(media_el.attrib.get('bitrate')) tbr = int_or_none(media_el.attrib.get('bitrate'))
formats.append({ formats.append({
'format_id': '-'.join(filter(None, [f4m_id, compat_str(i if tbr is None else tbr)])), 'format_id': '-'.join(filter(None, [f4m_id, compat_str(i if tbr is None else tbr)])),

View File

@ -1,5 +1,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
fix_xml_ampersands, fix_xml_ampersands,
@ -7,7 +9,6 @@ from ..utils import (
qualities, qualities,
strip_jsonp, strip_jsonp,
unified_strdate, unified_strdate,
url_basename,
) )
@ -37,8 +38,21 @@ class NPOBaseIE(InfoExtractor):
class NPOIE(NPOBaseIE): class NPOIE(NPOBaseIE):
IE_NAME = 'npo.nl' IE_NAME = 'npo'
_VALID_URL = r'https?://(?:www\.)?npo\.nl/(?!live|radio)[^/]+/[^/]+/(?P<id>[^/?]+)' IE_DESC = 'npo.nl and ntr.nl'
_VALID_URL = r'''(?x)
(?:
npo:|
https?://
(?:www\.)?
(?:
npo\.nl/(?!live|radio)(?:[^/]+/){2}|
ntr\.nl/(?:[^/]+/){2,}|
omroepwnl\.nl/video/fragment/[^/]+__
)
)
(?P<id>[^/?#]+)
'''
_TESTS = [ _TESTS = [
{ {
@ -58,7 +72,7 @@ class NPOIE(NPOBaseIE):
'info_dict': { 'info_dict': {
'id': 'VARA_101191800', 'id': 'VARA_101191800',
'ext': 'm4v', 'ext': 'm4v',
'title': 'De Mega Mike & Mega Thomas show', 'title': 'De Mega Mike & Mega Thomas show: The best of.',
'description': 'md5:3b74c97fc9d6901d5a665aac0e5400f4', 'description': 'md5:3b74c97fc9d6901d5a665aac0e5400f4',
'upload_date': '20090227', 'upload_date': '20090227',
'duration': 2400, 'duration': 2400,
@ -70,8 +84,8 @@ class NPOIE(NPOBaseIE):
'info_dict': { 'info_dict': {
'id': 'VPWON_1169289', 'id': 'VPWON_1169289',
'ext': 'm4v', 'ext': 'm4v',
'title': 'Tegenlicht', 'title': 'Tegenlicht: De toekomst komt uit Afrika',
'description': 'md5:d6476bceb17a8c103c76c3b708f05dd1', 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea',
'upload_date': '20130225', 'upload_date': '20130225',
'duration': 3000, 'duration': 3000,
}, },
@ -100,6 +114,30 @@ class NPOIE(NPOBaseIE):
'title': 'Hoe gaat Europa verder na Parijs?', 'title': 'Hoe gaat Europa verder na Parijs?',
}, },
}, },
{
'url': 'http://www.ntr.nl/Aap-Poot-Pies/27/detail/Aap-poot-pies/VPWON_1233944#content',
'md5': '01c6a2841675995da1f0cf776f03a9c3',
'info_dict': {
'id': 'VPWON_1233944',
'ext': 'm4v',
'title': 'Aap, poot, pies',
'description': 'md5:c9c8005d1869ae65b858e82c01a91fde',
'upload_date': '20150508',
'duration': 599,
},
},
{
'url': 'http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698',
'md5': 'd30cd8417b8b9bca1fdff27428860d08',
'info_dict': {
'id': 'POW_00996502',
'ext': 'm4v',
'title': '''"Dit is wel een 'landslide'..."''',
'description': 'md5:f8d66d537dfb641380226e31ca57b8e8',
'upload_date': '20150508',
'duration': 462,
},
}
] ]
def _real_extract(self, url): def _real_extract(self, url):
@ -114,6 +152,18 @@ class NPOIE(NPOBaseIE):
transform_source=strip_jsonp, transform_source=strip_jsonp,
) )
# For some videos actual video id (prid) is different (e.g. for
# http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698
# video id is POMS_WNL_853698 but prid is POW_00996502)
video_id = metadata.get('prid') or video_id
# titel is too generic in some cases so utilize aflevering_titel as well
# when available (e.g. http://tegenlicht.vpro.nl/afleveringen/2014-2015/access-to-africa.html)
title = metadata['titel']
sub_title = metadata.get('aflevering_titel')
if sub_title and sub_title != title:
title += ': %s' % sub_title
token = self._get_token(video_id) token = self._get_token(video_id)
formats = [] formats = []
@ -186,8 +236,8 @@ class NPOIE(NPOBaseIE):
return { return {
'id': video_id, 'id': video_id,
'title': metadata['titel'], 'title': title,
'description': metadata['info'], 'description': metadata.get('info'),
'thumbnail': metadata.get('images', [{'url': None}])[-1]['url'], 'thumbnail': metadata.get('images', [{'url': None}])[-1]['url'],
'upload_date': unified_strdate(metadata.get('gidsdatum')), 'upload_date': unified_strdate(metadata.get('gidsdatum')),
'duration': parse_duration(metadata.get('tijdsduur')), 'duration': parse_duration(metadata.get('tijdsduur')),
@ -356,9 +406,8 @@ class NPORadioFragmentIE(InfoExtractor):
} }
class TegenlichtVproIE(NPOIE): class VPROIE(NPOIE):
IE_NAME = 'tegenlicht.vpro.nl' _VALID_URL = r'https?://(?:www\.)?(?:tegenlicht\.)?vpro\.nl/(?:[^/]+/){2,}(?P<id>[^/]+)\.html'
_VALID_URL = r'https?://tegenlicht\.vpro\.nl/afleveringen/.*?'
_TESTS = [ _TESTS = [
{ {
@ -367,17 +416,72 @@ class TegenlichtVproIE(NPOIE):
'info_dict': { 'info_dict': {
'id': 'VPWON_1169289', 'id': 'VPWON_1169289',
'ext': 'm4v', 'ext': 'm4v',
'title': 'Tegenlicht', 'title': 'De toekomst komt uit Afrika',
'description': 'md5:d6476bceb17a8c103c76c3b708f05dd1', 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea',
'upload_date': '20130225', 'upload_date': '20130225',
}, },
}, },
{
'url': 'http://www.vpro.nl/programmas/2doc/2015/sergio-herman.html',
'info_dict': {
'id': 'sergio-herman',
'title': 'Sergio Herman: Fucking perfect',
},
'playlist_count': 2,
},
{
# playlist with youtube embed
'url': 'http://www.vpro.nl/programmas/2doc/2015/education-education.html',
'info_dict': {
'id': 'education-education',
'title': '2Doc',
},
'playlist_count': 2,
}
] ]
def _real_extract(self, url): def _real_extract(self, url):
name = url_basename(url) playlist_id = self._match_id(url)
webpage = self._download_webpage(url, name)
urn = self._html_search_meta('mediaurn', webpage) webpage = self._download_webpage(url, playlist_id)
info_page = self._download_json(
'http://rs.vpro.nl/v2/api/media/%s.json' % urn, name) entries = [
return self._get_info(info_page['mid']) self.url_result('npo:%s' % video_id if not video_id.startswith('http') else video_id)
for video_id in re.findall(r'data-media-id="([^"]+)"', webpage)
]
playlist_title = self._search_regex(
r'<title>\s*([^>]+?)\s*-\s*Teledoc\s*-\s*VPRO\s*</title>',
webpage, 'playlist title', default=None) or self._og_search_title(webpage)
return self.playlist_result(entries, playlist_id, playlist_title)
class WNLIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?omroepwnl\.nl/video/detail/(?P<id>[^/]+)__\d+'
_TEST = {
'url': 'http://www.omroepwnl.nl/video/detail/vandaag-de-dag-6-mei__060515',
'info_dict': {
'id': 'vandaag-de-dag-6-mei',
'title': 'Vandaag de Dag 6 mei',
},
'playlist_count': 4,
}
def _real_extract(self, url):
playlist_id = self._match_id(url)
webpage = self._download_webpage(url, playlist_id)
entries = [
self.url_result('npo:%s' % video_id, 'NPO')
for video_id, part in re.findall(
r'<a[^>]+href="([^"]+)"[^>]+class="js-mid"[^>]*>(Deel \d+)', webpage)
]
playlist_title = self._html_search_regex(
r'(?s)<h1[^>]+class="subject"[^>]*>(.+?)</h1>',
webpage, 'playlist title')
return self.playlist_result(entries, playlist_id, playlist_title)

View File

@ -9,8 +9,9 @@ from ..compat import (
compat_urllib_parse, compat_urllib_parse,
) )
from ..utils import ( from ..utils import (
unified_strdate, determine_ext,
int_or_none, int_or_none,
unified_strdate,
) )
@ -21,6 +22,11 @@ class ProSiebenSat1IE(InfoExtractor):
_TESTS = [ _TESTS = [
{ {
# Tests changes introduced in https://github.com/rg3/youtube-dl/pull/6242
# in response to fixing https://github.com/rg3/youtube-dl/issues/6215:
# - malformed f4m manifest support
# - proper handling of URLs starting with `https?://` in 2.0 manifests
# - recursive child f4m manifests extraction
'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge', 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge',
'info_dict': { 'info_dict': {
'id': '2104602', 'id': '2104602',
@ -208,7 +214,7 @@ class ProSiebenSat1IE(InfoExtractor):
clip_id = self._html_search_regex(self._CLIPID_REGEXES, webpage, 'clip id') clip_id = self._html_search_regex(self._CLIPID_REGEXES, webpage, 'clip id')
access_token = 'prosieben' access_token = 'prosieben'
client_name = 'kolibri-1.12.6' client_name = 'kolibri-2.0.19-splec4'
client_location = url client_location = url
videos_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse.urlencode({ videos_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse.urlencode({
@ -275,8 +281,9 @@ class ProSiebenSat1IE(InfoExtractor):
for source in urls_sources: for source in urls_sources:
protocol = source['protocol'] protocol = source['protocol']
source_url = source['url']
if protocol == 'rtmp' or protocol == 'rtmpe': if protocol == 'rtmp' or protocol == 'rtmpe':
mobj = re.search(r'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source['url']) mobj = re.search(r'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source_url)
if not mobj: if not mobj:
continue continue
path = mobj.group('path') path = mobj.group('path')
@ -293,9 +300,11 @@ class ProSiebenSat1IE(InfoExtractor):
'ext': 'mp4', 'ext': 'mp4',
'format_id': '%s_%s' % (source['cdn'], source['bitrate']), 'format_id': '%s_%s' % (source['cdn'], source['bitrate']),
}) })
elif 'f4mgenerator' in source_url or determine_ext(source_url) == 'f4m':
formats.extend(self._extract_f4m_formats(source_url, clip_id))
else: else:
formats.append({ formats.append({
'url': source['url'], 'url': source_url,
'vbr': fix_bitrate(source['bitrate']), 'vbr': fix_bitrate(source['bitrate']),
}) })