mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 pukkandan
					pukkandan