]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/common.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / common.py
index 3701fe6b3f6b1944dc5c56de027dd0f02874b30c..c2b9970ec880012b8afca0e9a0bccd309acbde5d 100644 (file)
@@ -1699,7 +1699,14 @@ def __init__(ie, *args, **kwargs):
         return FormatSort
 
     def _sort_formats(self, formats, field_preference=[]):
-        if formats and field_preference:
+        if not field_preference:
+            self._downloader.deprecation_warning(
+                'yt_dlp.InfoExtractor._sort_formats is deprecated and is no longer required')
+            return
+        self._downloader.deprecation_warning(
+            'yt_dlp.InfoExtractor._sort_formats is deprecated and no longer works as expected. '
+            'Return _format_sort_fields in the info_dict instead')
+        if formats:
             formats[0]['__sort_fields'] = field_preference
 
     def _check_formats(self, formats, video_id):
@@ -2431,7 +2438,6 @@ def _parse_xspf(self, xspf_doc, playlist_id, xspf_url=None, xspf_base_url=None):
                     'width': int_or_none(location.get(xpath_with_ns('s1:width', NS_MAP))),
                     'height': int_or_none(location.get(xpath_with_ns('s1:height', NS_MAP))),
                 })
-            self._sort_formats(formats)
 
             entries.append({
                 'id': playlist_id,
@@ -3269,7 +3275,6 @@ def _parse_jwplayer_data(self, jwplayer_data, video_id=None, require_title=True,
                     'url': formats[0]['url'],
                 })
             else:
-                self._sort_formats(formats)
                 entry['formats'] = formats
             entries.append(entry)
         if len(entries) == 1: