mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-12-17 06:35:42 +07:00
@@ -67,6 +67,7 @@
|
||||
EntryNotInPlaylist,
|
||||
ExistingVideoReached,
|
||||
ExtractorError,
|
||||
FormatSorter,
|
||||
GeoRestrictedError,
|
||||
HEADRequest,
|
||||
ISO3166Utils,
|
||||
@@ -2461,6 +2462,18 @@ def _raise_pending_errors(self, info):
|
||||
if err:
|
||||
self.report_error(err, tb=False)
|
||||
|
||||
def sort_formats(self, info_dict):
|
||||
formats = self._get_formats(info_dict)
|
||||
if not formats:
|
||||
return
|
||||
# Backward compatibility with InfoExtractor._sort_formats
|
||||
field_preference = formats[0].pop('__sort_fields', None)
|
||||
if field_preference:
|
||||
info_dict['_format_sort_fields'] = field_preference
|
||||
|
||||
formats.sort(key=FormatSorter(
|
||||
self, info_dict.get('_format_sort_fields', [])).calculate_preference)
|
||||
|
||||
def process_video_result(self, info_dict, download=True):
|
||||
assert info_dict.get('_type', 'video') == 'video'
|
||||
self._num_videos += 1
|
||||
@@ -2546,6 +2559,7 @@ def sanitize_numeric_fields(info):
|
||||
info_dict['requested_subtitles'] = self.process_subtitles(
|
||||
info_dict['id'], subtitles, automatic_captions)
|
||||
|
||||
self.sort_formats(info_dict)
|
||||
formats = self._get_formats(info_dict)
|
||||
|
||||
# or None ensures --clean-infojson removes it
|
||||
|
||||
Reference in New Issue
Block a user