[wdr] Simplify extraction

master
Yen Chi Hsuan 8 years ago
parent 50918c4ee0
commit 6869d634c6
No known key found for this signature in database
GPG Key ID: 3FDDD575826C5C30

@ -10,6 +10,7 @@ from ..utils import (
strip_jsonp, strip_jsonp,
unified_strdate, unified_strdate,
ExtractorError, ExtractorError,
update_url_query,
urlhandle_detect_ext, urlhandle_detect_ext,
) )
@ -100,9 +101,10 @@ class WDRIE(InfoExtractor):
}, },
{ {
'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html', 'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html',
# Live stream, MD5 unstable
'info_dict': { 'info_dict': {
'id': 'mdb-869971', 'id': 'mdb-869971',
'ext': 'mp3', 'ext': 'flv',
'title': 'Funkhaus Europa Livestream', 'title': 'Funkhaus Europa Livestream',
'description': 'md5:2309992a6716c347891c045be50992e4', 'description': 'md5:2309992a6716c347891c045be50992e4',
'upload_date': '20160101', 'upload_date': '20160101',
@ -150,36 +152,38 @@ class WDRIE(InfoExtractor):
formats = [] formats = []
# check if the metadata contains a direct URL to a file # check if the metadata contains a direct URL to a file
metadata_media_alt = metadata_media_resource.get('alt') for kind, media_resource in metadata_media_resource.items():
if metadata_media_alt: if kind not in ('dflt', 'alt'):
for tag_name in ['videoURL', 'audioURL']: continue
if tag_name in metadata_media_alt:
alt_url = metadata_media_alt[tag_name] for tag_name, medium_url in media_resource.items():
ext = determine_ext(alt_url) if tag_name not in ('videoURL', 'audioURL'):
if ext == 'm3u8': continue
m3u_fmt = self._extract_m3u8_formats(
alt_url, display_id, 'mp4', 'm3u8_native', ext = determine_ext(medium_url)
m3u8_id='hls') if ext == 'm3u8':
formats.extend(m3u_fmt) m3u_fmt = self._extract_m3u8_formats(
else: medium_url, display_id, 'mp4', 'm3u8_native',
a_format = { m3u8_id='hls')
'url': alt_url formats.extend(m3u_fmt)
} elif ext == 'f4m':
if ext == 'unknown_video': manifest_url = update_url_query(
urlh = self._request_webpage( medium_url, {'hdcore': '3.2.0', 'plugin': 'aasp-3.2.0.77.18'})
alt_url, display_id, note='Determining extension') formats.extend(self._extract_f4m_formats(
ext = urlhandle_detect_ext(urlh) manifest_url, display_id, f4m_id='hds', fatal=False))
a_format['ext'] = ext elif ext == 'smil':
formats.append(a_format) formats.extend(self._extract_smil_formats(
medium_url, 'stream', fatal=False))
# check if there are flash-streams for this video else:
if 'dflt' in metadata_media_resource and 'videoURL' in metadata_media_resource['dflt']: a_format = {
video_url = metadata_media_resource['dflt']['videoURL'] 'url': medium_url
if video_url.endswith('.f4m'): }
full_video_url = video_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18' if ext == 'unknown_video':
formats.extend(self._extract_f4m_formats(full_video_url, display_id, f4m_id='hds', fatal=False)) urlh = self._request_webpage(
elif video_url.endswith('.smil'): medium_url, display_id, note='Determining extension')
formats.extend(self._extract_smil_formats(video_url, 'stream', fatal=False)) ext = urlhandle_detect_ext(urlh)
a_format['ext'] = ext
formats.append(a_format)
subtitles = {} subtitles = {}
caption_url = metadata_media_resource.get('captionURL') caption_url = metadata_media_resource.get('captionURL')

Loading…
Cancel
Save