mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-09 12:42:28 +01:00
[youtube] Improve format sorting for IOS formats
When no itag/resolution is available for reference, use the closest resolution
This commit is contained in:
parent
460eb9c50e
commit
5c6d2ef9d1
@ -3168,7 +3168,7 @@ def append_client(*client_names):
|
|||||||
|
|
||||||
def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, is_live, duration):
|
def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, is_live, duration):
|
||||||
itags, stream_ids = {}, []
|
itags, stream_ids = {}, []
|
||||||
itag_qualities, res_qualities = {}, {}
|
itag_qualities, res_qualities = {}, {0: -1}
|
||||||
q = qualities([
|
q = qualities([
|
||||||
# Normally tiny is the smallest video-only formats. But
|
# Normally tiny is the smallest video-only formats. But
|
||||||
# audio-only formats with unknown quality may get tagged as tiny
|
# audio-only formats with unknown quality may get tagged as tiny
|
||||||
@ -3320,10 +3320,9 @@ def process_manifest_format(f, proto, itag):
|
|||||||
f['format_id'] = itag
|
f['format_id'] = itag
|
||||||
itags[itag] = proto
|
itags[itag] = proto
|
||||||
|
|
||||||
f['quality'] = next((
|
f['quality'] = itag_qualities.get(try_get(f, lambda f: f['format_id'].split('-')[0]), -1)
|
||||||
q(qdict[val])
|
if f['quality'] == -1 and f.get('height'):
|
||||||
for val, qdict in ((f.get('format_id', '').split('-')[0], itag_qualities), (f.get('height'), res_qualities))
|
f['quality'] = q(res_qualities[min(res_qualities, key=lambda x: abs(x - f['height']))])
|
||||||
if val in qdict), -1)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user