Better audio sorting in ytdl

This commit is contained in:
Maksym Pavlenko
2017-08-22 09:34:00 -07:00
parent 7c3d626887
commit 1836a55550
+4 -1
View File
@@ -94,7 +94,10 @@ def _choose_url(info, quality):
# Sort list by field (width for videos, file size for audio)
sort_field = 'width' if is_video else 'filesize'
ordered = sorted(fmt_list, key=lambda x: x[sort_field] or x['format_id'], reverse=True)
# Sometime 'filesize' field can be None
if not all(x[sort_field] is not None for x in fmt_list):
sort_field = 'format_id'
ordered = sorted(fmt_list, key=lambda x: x[sort_field], reverse=True)
# Choose an item depending on quality, better at the beginning
is_high_quality = quality == 'videohigh' or quality == 'audiohigh'