mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-05 18:39:37 +02:00
[FormatSort] Fix bug for audio with unknown codec
This commit is contained in:
parent
e4f0275711
commit
f5510afef0
@ -1756,6 +1756,7 @@ def _merge(formats_pair):
|
|||||||
if not allow_multiple_streams[aud_vid] and fmt_info.get(aud_vid[0] + 'codec') != 'none':
|
if not allow_multiple_streams[aud_vid] and fmt_info.get(aud_vid[0] + 'codec') != 'none':
|
||||||
if get_no_more[aud_vid]:
|
if get_no_more[aud_vid]:
|
||||||
formats_info.pop(i)
|
formats_info.pop(i)
|
||||||
|
break
|
||||||
get_no_more[aud_vid] = True
|
get_no_more[aud_vid] = True
|
||||||
|
|
||||||
if len(formats_info) == 1:
|
if len(formats_info) == 1:
|
||||||
|
@ -1497,7 +1497,7 @@ class FormatSort:
|
|||||||
'order': ('m4a', 'aac', 'mp3', 'ogg', 'opus', 'webm', '', 'none'),
|
'order': ('m4a', 'aac', 'mp3', 'ogg', 'opus', 'webm', '', 'none'),
|
||||||
'order_free': ('opus', 'ogg', 'webm', 'm4a', 'mp3', 'aac', '', 'none')},
|
'order_free': ('opus', 'ogg', 'webm', 'm4a', 'mp3', 'aac', '', 'none')},
|
||||||
'hidden': {'visible': False, 'forced': True, 'type': 'extractor', 'max': -1000},
|
'hidden': {'visible': False, 'forced': True, 'type': 'extractor', 'max': -1000},
|
||||||
'aud_or_vid': {'visible': False, 'forced': True, 'type': 'multiple', 'default': 1,
|
'aud_or_vid': {'visible': False, 'forced': True, 'type': 'multiple',
|
||||||
'field': ('vcodec', 'acodec'),
|
'field': ('vcodec', 'acodec'),
|
||||||
'function': lambda it: int(any(v != 'none' for v in it))},
|
'function': lambda it: int(any(v != 'none' for v in it))},
|
||||||
'ie_pref': {'priority': True, 'type': 'extractor'},
|
'ie_pref': {'priority': True, 'type': 'extractor'},
|
||||||
@ -1521,7 +1521,8 @@ class FormatSort:
|
|||||||
'br': {'type': 'combined', 'field': ('tbr', 'vbr', 'abr'), 'same_limit': True},
|
'br': {'type': 'combined', 'field': ('tbr', 'vbr', 'abr'), 'same_limit': True},
|
||||||
'size': {'type': 'combined', 'same_limit': True, 'field': ('filesize', 'fs_approx')},
|
'size': {'type': 'combined', 'same_limit': True, 'field': ('filesize', 'fs_approx')},
|
||||||
'ext': {'type': 'combined', 'field': ('vext', 'aext')},
|
'ext': {'type': 'combined', 'field': ('vext', 'aext')},
|
||||||
'res': {'type': 'multiple', 'field': ('height', 'width'), 'function': min},
|
'res': {'type': 'multiple', 'field': ('height', 'width'),
|
||||||
|
'function': lambda it: (lambda l: min(l) if l else 0)(tuple(filter(None, it)))},
|
||||||
|
|
||||||
# Most of these exist only for compatibility reasons
|
# Most of these exist only for compatibility reasons
|
||||||
'dimension': {'type': 'alias', 'field': 'res'},
|
'dimension': {'type': 'alias', 'field': 'res'},
|
||||||
@ -1565,7 +1566,7 @@ def _get_field_setting(self, field, key):
|
|||||||
elif key == 'convert':
|
elif key == 'convert':
|
||||||
default = 'order' if type == 'ordered' else 'float_string' if field else 'ignore'
|
default = 'order' if type == 'ordered' else 'float_string' if field else 'ignore'
|
||||||
else:
|
else:
|
||||||
default = {'type': 'field', 'visible': True, 'order': [], 'not_in_list': (None,), 'function': max}.get(key, None)
|
default = {'type': 'field', 'visible': True, 'order': [], 'not_in_list': (None,)}.get(key, None)
|
||||||
propObj[key] = default
|
propObj[key] = default
|
||||||
return propObj[key]
|
return propObj[key]
|
||||||
|
|
||||||
@ -1705,11 +1706,7 @@ def _calculate_field_preference(self, format, field):
|
|||||||
type = 'field' # Only 'field' is allowed in multiple for now
|
type = 'field' # Only 'field' is allowed in multiple for now
|
||||||
actual_fields = self._get_field_setting(field, 'field')
|
actual_fields = self._get_field_setting(field, 'field')
|
||||||
|
|
||||||
def wrapped_function(values):
|
value = self._get_field_setting(field, 'function')(get_value(f) for f in actual_fields)
|
||||||
values = tuple(filter(lambda x: x is not None, values))
|
|
||||||
return self._get_field_setting(field, 'function')(values) if values else None
|
|
||||||
|
|
||||||
value = wrapped_function((get_value(f) for f in actual_fields))
|
|
||||||
else:
|
else:
|
||||||
value = get_value(field)
|
value = get_value(field)
|
||||||
return self._calculate_field_preference_from_value(format, field, type, value)
|
return self._calculate_field_preference_from_value(format, field, type, value)
|
||||||
|
Loading…
Reference in New Issue
Block a user