1
0
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-12-25 02:46:54 +00:00

[rtlnl] Improve extraction (Closes #9329)

* Make hls extraction non fatal and revert ext
* Extract progressive formats' metadata from corresponding hls formats
This commit is contained in:
Sergey M․ 2016-04-30 01:43:39 +06:00
parent 5556047465
commit 0571ffda7d
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -94,33 +94,44 @@ class RtlNlIE(InfoExtractor):
videopath = material['videopath'] videopath = material['videopath']
m3u8_url = meta.get('videohost', 'http://manifest.us.rtl.nl') + videopath m3u8_url = meta.get('videohost', 'http://manifest.us.rtl.nl') + videopath
formats = self._extract_m3u8_formats(m3u8_url, uuid) formats = self._extract_m3u8_formats(
m3u8_url, uuid, 'mp4', m3u8_id='hls', fatal=False)
video_urlpart = videopath.split('/adaptive/')[1][:-5] video_urlpart = videopath.split('/adaptive/')[1][:-5]
PG_URL_TEMPLATE = 'http://pg.us.rtl.nl/rtlxl/network/%s/progressive/%s.mp4' PG_URL_TEMPLATE = 'http://pg.us.rtl.nl/rtlxl/network/%s/progressive/%s.mp4'
formats.extend([ PG_FORMATS = (
{ ('a2t', 512, 288),
'url': PG_URL_TEMPLATE % ('a2t', video_urlpart), ('a3t', 704, 400),
'format_id': 'a2t', ('nettv', 1280, 720),
'width': 512, )
'height': 288,
}, def pg_format(format_id, width, height):
{ return {
'url': PG_URL_TEMPLATE % ('a3t', video_urlpart), 'url': PG_URL_TEMPLATE % (format_id, video_urlpart),
'format_id': 'a3t', 'format_id': 'pg-%s' % format_id,
'width': 704, 'protocol': 'http',
'height': 400, 'width': width,
'quality': 0, 'height': height,
},
{
'url': PG_URL_TEMPLATE % ('nettv', video_urlpart),
'format_id': 'nettv',
'width': 1280,
'height': 720,
'quality': 0,
} }
])
if not formats:
formats = [pg_format(*pg_tuple) for pg_tuple in PG_FORMATS]
else:
pg_formats = []
for format_id, width, height in PG_FORMATS:
try:
# Find hls format with the same width and height corresponding
# to progressive format and copy metadata from it.
f = next(f for f in formats
if f.get('width') == width and f.get('height') == height).copy()
f.update(pg_format(format_id, width, height))
pg_formats.append(f)
except StopIteration:
# Missing hls format does mean that no progressive format with
# such width and height exists either.
pass
formats.extend(pg_formats)
self._sort_formats(formats) self._sort_formats(formats)
thumbnails = [] thumbnails = []