[abc:iview] extract from both 'hls' and 'hls-latest'

This ensures backward compatibility by also providing the pre-merged formats
This commit is contained in:
ClosedPort22 2024-06-27 21:53:15 +08:00
parent fcc727b755
commit 16ed8814be
No known key found for this signature in database

View file

@ -329,14 +329,19 @@ def tokenize_url(url, token):
'hdnea': token, 'hdnea': token,
}) })
for sd_url in traverse_obj(stream, ('streams', 'hls-latest', ('1080', '720', 'sd', 'sd-low'), {str})): formats = []
if not sd_url: # hls: pre-merged formats
continue # hls-latest: same as hls, but sometimes has separate audio tracks
formats = self._extract_m3u8_formats( # Note: pre-merged formats in hls-latest are treated as video-only if audio-only tracks
tokenize_url(sd_url, token), video_id, 'mp4', # are present, so we extract both types
entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) for label in ('hls', 'hls-latest'):
if formats: for sd_url in traverse_obj(stream, ('streams', label, ('1080', '720', 'sd', 'sd-low'), {str})):
break fmts = self._extract_m3u8_formats(
tokenize_url(sd_url, token), video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id=label, fatal=False)
if fmts:
formats.extend(fmts)
break
subtitles = {} subtitles = {}
src_vtt = traverse_obj(stream, ('captions', 'src-vtt')) src_vtt = traverse_obj(stream, ('captions', 'src-vtt'))