forked from minhngoc25a/youtube-dl
[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:
parent
5556047465
commit
0571ffda7d
|
@ -94,33 +94,44 @@ class RtlNlIE(InfoExtractor):
|
|||
videopath = material['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]
|
||||
PG_URL_TEMPLATE = 'http://pg.us.rtl.nl/rtlxl/network/%s/progressive/%s.mp4'
|
||||
|
||||
formats.extend([
|
||||
{
|
||||
'url': PG_URL_TEMPLATE % ('a2t', video_urlpart),
|
||||
'format_id': 'a2t',
|
||||
'width': 512,
|
||||
'height': 288,
|
||||
},
|
||||
{
|
||||
'url': PG_URL_TEMPLATE % ('a3t', video_urlpart),
|
||||
'format_id': 'a3t',
|
||||
'width': 704,
|
||||
'height': 400,
|
||||
'quality': 0,
|
||||
},
|
||||
{
|
||||
'url': PG_URL_TEMPLATE % ('nettv', video_urlpart),
|
||||
'format_id': 'nettv',
|
||||
'width': 1280,
|
||||
'height': 720,
|
||||
'quality': 0,
|
||||
PG_FORMATS = (
|
||||
('a2t', 512, 288),
|
||||
('a3t', 704, 400),
|
||||
('nettv', 1280, 720),
|
||||
)
|
||||
|
||||
def pg_format(format_id, width, height):
|
||||
return {
|
||||
'url': PG_URL_TEMPLATE % (format_id, video_urlpart),
|
||||
'format_id': 'pg-%s' % format_id,
|
||||
'protocol': 'http',
|
||||
'width': width,
|
||||
'height': height,
|
||||
}
|
||||
])
|
||||
|
||||
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)
|
||||
|
||||
thumbnails = []
|
||||
|
|
Loading…
Reference in New Issue