mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-10 15:14:57 +00:00
[extractor/youtube] Fix bug in format sorting
This commit is contained in:
parent
90a1df305b
commit
b25cac650f
1 changed files with 2 additions and 2 deletions
|
@ -3199,7 +3199,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
|
|
||||||
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 = {}, {0: -1}
|
itag_qualities, res_qualities = {}, {0: None}
|
||||||
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
|
||||||
|
@ -3357,7 +3357,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
f['format_id'] = itag
|
f['format_id'] = itag
|
||||||
itags[itag] = proto
|
itags[itag] = proto
|
||||||
|
|
||||||
f['quality'] = itag_qualities.get(try_get(f, lambda f: f['format_id'].split('-')[0]), -1)
|
f['quality'] = q(itag_qualities.get(try_get(f, lambda f: f['format_id'].split('-')[0]), -1))
|
||||||
if f['quality'] == -1 and f.get('height'):
|
if f['quality'] == -1 and f.get('height'):
|
||||||
f['quality'] = q(res_qualities[min(res_qualities, key=lambda x: abs(x - f['height']))])
|
f['quality'] = q(res_qualities[min(res_qualities, key=lambda x: abs(x - f['height']))])
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue