mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-12-06 06:45:00 +01:00
parent
d0d74b7197
commit
784320c98c
2 changed files with 17 additions and 3 deletions
|
|
@ -67,6 +67,7 @@ from .utils import (
|
|||
EntryNotInPlaylist,
|
||||
ExistingVideoReached,
|
||||
ExtractorError,
|
||||
FormatSorter,
|
||||
GeoRestrictedError,
|
||||
HEADRequest,
|
||||
ISO3166Utils,
|
||||
|
|
@ -2461,6 +2462,18 @@ class YoutubeDL:
|
|||
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 @@ class YoutubeDL:
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue