aboutsummaryrefslogtreecommitdiff
path: root/yt_dlp/utils/_utils.py
diff options
context:
space:
mode:
authorSimon Sawicki <contact@grub4k.xyz>2024-10-27 00:17:26 +0200
committerGitHub <noreply@github.com>2024-10-27 00:17:26 +0200
commit5c880ef42e9c2b2fc412f6d69dad37d34fb75a62 (patch)
tree200ea3c0318c8610cd63f6caeec6e20e9bf36b4e /yt_dlp/utils/_utils.py
parent21cdcf03a237a0c4979c941d5a5385cae44c7906 (diff)
[core] Populate format sorting fields before dependent fields (#11353)
Authored by: Grub4K
Diffstat (limited to 'yt_dlp/utils/_utils.py')
-rw-r--r--yt_dlp/utils/_utils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/yt_dlp/utils/_utils.py b/yt_dlp/utils/_utils.py
index 7aff67ddf..b7de04e63 100644
--- a/yt_dlp/utils/_utils.py
+++ b/yt_dlp/utils/_utils.py
@@ -5578,14 +5578,15 @@ class FormatSorter:
value = get_value(field)
return self._calculate_field_preference_from_value(format_, field, type_, value)
- def calculate_preference(self, format):
+ @staticmethod
+ def _fill_sorting_fields(format):
# Determine missing protocol
if not format.get('protocol'):
format['protocol'] = determine_protocol(format)
# Determine missing ext
if not format.get('ext') and 'url' in format:
- format['ext'] = determine_ext(format['url'])
+ format['ext'] = determine_ext(format['url']).lower()
if format.get('vcodec') == 'none':
format['audio_ext'] = format['ext'] if format.get('acodec') != 'none' else 'none'
format['video_ext'] = 'none'
@@ -5613,6 +5614,8 @@ class FormatSorter:
if not format.get('tbr'):
format['tbr'] = try_call(lambda: format['vbr'] + format['abr']) or None
+ def calculate_preference(self, format):
+ self._fill_sorting_fields(format)
return tuple(self._calculate_field_preference(format, field) for field in self._order)