0
0
Fork 0

[wdr] Simplify extraction

main
Yen Chi Hsuan 2016-06-09 13:41:12 +08:00
parent 50918c4ee0
commit 6869d634c6
No known key found for this signature in database
GPG Key ID: 3FDDD575826C5C30
1 changed files with 34 additions and 30 deletions

View File

@ -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]
ext = determine_ext(alt_url)
if ext == 'm3u8':
m3u_fmt = self._extract_m3u8_formats(
alt_url, display_id, 'mp4', 'm3u8_native',
m3u8_id='hls')
formats.extend(m3u_fmt)
else:
a_format = {
'url': alt_url
}
if ext == 'unknown_video':
urlh = self._request_webpage(
alt_url, display_id, note='Determining extension')
ext = urlhandle_detect_ext(urlh)
a_format['ext'] = ext
formats.append(a_format)
# check if there are flash-streams for this video for tag_name, medium_url in media_resource.items():
if 'dflt' in metadata_media_resource and 'videoURL' in metadata_media_resource['dflt']: if tag_name not in ('videoURL', 'audioURL'):
video_url = metadata_media_resource['dflt']['videoURL'] continue
if video_url.endswith('.f4m'):
full_video_url = video_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18' ext = determine_ext(medium_url)
formats.extend(self._extract_f4m_formats(full_video_url, display_id, f4m_id='hds', fatal=False)) if ext == 'm3u8':
elif video_url.endswith('.smil'): m3u_fmt = self._extract_m3u8_formats(
formats.extend(self._extract_smil_formats(video_url, 'stream', fatal=False)) medium_url, display_id, 'mp4', 'm3u8_native',
m3u8_id='hls')
formats.extend(m3u_fmt)
elif ext == 'f4m':
manifest_url = update_url_query(
medium_url, {'hdcore': '3.2.0', 'plugin': 'aasp-3.2.0.77.18'})
formats.extend(self._extract_f4m_formats(
manifest_url, display_id, f4m_id='hds', fatal=False))
elif ext == 'smil':
formats.extend(self._extract_smil_formats(
medium_url, 'stream', fatal=False))
else:
a_format = {
'url': medium_url
}
if ext == 'unknown_video':
urlh = self._request_webpage(
medium_url, display_id, note='Determining extension')
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')