]> jfr.im git - yt-dlp.git/commitdiff
[formatsort] Remove unnecessary `field_preference` from extractors
authorpukkandan <redacted>
Thu, 18 Feb 2021 18:22:28 +0000 (23:52 +0530)
committerpukkandan <redacted>
Thu, 18 Feb 2021 18:22:28 +0000 (23:52 +0530)
These were written with the old format sorting in mind and is no longer needed

20 files changed:
youtube_dlc/extractor/alura.py
youtube_dlc/extractor/aol.py
youtube_dlc/extractor/aparat.py
youtube_dlc/extractor/arcpublishing.py
youtube_dlc/extractor/crunchyroll.py
youtube_dlc/extractor/leeco.py
youtube_dlc/extractor/linkedin.py
youtube_dlc/extractor/massengeschmacktv.py
youtube_dlc/extractor/nytimes.py
youtube_dlc/extractor/pinterest.py
youtube_dlc/extractor/reddit.py
youtube_dlc/extractor/sendtonews.py
youtube_dlc/extractor/spankbang.py
youtube_dlc/extractor/spankwire.py
youtube_dlc/extractor/threeqsdn.py
youtube_dlc/extractor/udemy.py
youtube_dlc/extractor/umg.py
youtube_dlc/extractor/viewlift.py
youtube_dlc/extractor/vimeo.py
youtube_dlc/extractor/xhamster.py

index 36b4d95b3db1a5f4dd6b68e236c341442f2a45e6..2681bfc18d4200949b765824255df13fa51a3d79 100644 (file)
@@ -67,7 +67,7 @@ def _real_extract(self, url):
                             f['height'] = int('720' if m.group('res') == 'hd' else '480')
                 formats.extend(video_format)
 
-            self._sort_formats(formats, field_preference=('height', 'width', 'tbr', 'format_id'))
+            self._sort_formats(formats)
 
             return {
                 'id': video_id,
index f6ecb8438fdaeafe365c35d93640c6197ed32089..133b5e25410f2455f847d1f547defa64e61abdfc 100644 (file)
@@ -125,7 +125,7 @@ def _real_extract(self, url):
                         'height': int_or_none(qs.get('h', [None])[0]),
                     })
                 formats.append(f)
-        self._sort_formats(formats, ('width', 'height', 'tbr', 'format_id'))
+        self._sort_formats(formats)
 
         return {
             'id': video_id,
index a9527e78550297e416baa9afa11ee01c767daf3c..da06a3cac2a0f3328013276266ddd7760e4cd19e 100644 (file)
@@ -72,8 +72,7 @@ def _real_extract(self, url):
                             r'(\d+)[pP]', label or '', 'height',
                             default=None)),
                     })
-        self._sort_formats(
-            formats, field_preference=('height', 'width', 'tbr', 'format_id'))
+        self._sort_formats(formats)
 
         info = self._search_json_ld(webpage, video_id, default={})
 
index ca6a6c4d87f9f13a259f8402f5e7ef51ad097088..48b83ce5896cc8323247b1c04f8e567b87c1cf4b 100644 (file)
@@ -152,8 +152,7 @@ def _real_extract(self, url):
                     'url': s_url,
                     'preference': -1,
                 })
-        self._sort_formats(
-            formats, ('preference', 'width', 'height', 'vbr', 'filesize', 'tbr', 'ext', 'format_id'))
+        self._sort_formats(formats)
 
         subtitles = {}
         for subtitle in (try_get(video, lambda x: x['subtitles']['urls'], list) or []):
index bc2d1fa8b041e3ec1bbc4d6d1b5f055ac31ee140..47892544f51e75fa9a0bc5d7e65372601dcac3ff 100644 (file)
@@ -571,7 +571,7 @@ def _real_extract(self, url):
                         'ext': 'flv',
                     })
                     formats.append(format_info)
-        self._sort_formats(formats, ('preference', 'language_preference', 'height', 'width', 'tbr', 'fps'))
+        self._sort_formats(formats)
 
         metadata = self._call_rpc_api(
             'VideoPlayer_GetMediaMetadata', video_id,
index 7dc0ad7947a8b3ddfa7713f5f2fe231cf9a1ebf5..d5e11423ca1855c8e24426a8c26a14dce3af53c7 100644 (file)
@@ -185,7 +185,7 @@ def get_flash_urls(media_url, format_id):
                     f['height'] = int_or_none(format_id[:-1])
 
                 formats.append(f)
-        self._sort_formats(formats, ('height', 'quality', 'format_id'))
+        self._sort_formats(formats, ('res', 'quality'))
 
         publish_time = parse_iso8601(self._html_search_regex(
             r'发布时间&nbsp;([^<>]+) ', page, 'publish time', default=None),
index 26fc703d1a8f764bb6728cfac9441a43a40bc1c9..e1dca4899e325222904841ce0e9801ea56264e1c 100644 (file)
@@ -124,7 +124,10 @@ def _real_extract(self, url):
                 streaming_url, video_slug, 'mp4',
                 'm3u8_native', m3u8_id='hls', fatal=False))
 
-        self._sort_formats(formats, ('width', 'height', 'source_preference', 'tbr', 'abr'))
+        # It seems like this would be correctly handled by default
+        # However, unless someone can confirm this, the old
+        # behaviour is being kept as-is
+        self._sort_formats(formats, ('res', 'source_preference'))
 
         return {
             'id': self._get_video_id(video_data, course_slug, video_slug),
index cfcc6b2245f15a851e8691b0d6ba7e61696b3a63..b381d31b48fe3c9388da3196e2c77df4286e09a1 100644 (file)
@@ -67,7 +67,7 @@ def _real_extract(self, url):
                 'vcodec': 'none' if format_id.startswith('Audio') else None,
             })
 
-        self._sort_formats(formats, ('width', 'height', 'filesize', 'tbr'))
+        self._sort_formats(formats)
 
         return {
             'id': episode,
index 976b1c6944e771b8332e8ac85fe7a5292c972aea..1f03a9462d27a1fefdc0ac33e42a129ee9ef3d80 100644 (file)
@@ -72,7 +72,7 @@ def get_file_size(file_size):
                     'tbr': int_or_none(video.get('bitrate'), 1000) or None,
                     'ext': ext,
                 })
-        self._sort_formats(formats, ('height', 'width', 'filesize', 'tbr', 'fps', 'format_id'))
+        self._sort_formats(formats)
 
         thumbnails = []
         for image in video_data.get('images', []):
index b249c9eda87988fc629af40c431d723a2850a91e..15c11a755aca40318a24412c0bea98841c44f0fe 100644 (file)
@@ -54,8 +54,7 @@ def _extract_video(self, data, extract_formats=True):
                         'height': int_or_none(format_dict.get('height')),
                         'duration': duration,
                     })
-            self._sort_formats(
-                formats, field_preference=('height', 'width', 'tbr', 'format_id'))
+            self._sort_formats(formats)
 
         description = data.get('description') or data.get('description_html') or data.get('seo_description')
         timestamp = unified_timestamp(data.get('created_at'))
index 77f66c9664d5cb2cc21a9abb80b067bd04e57839..222fa0172adc4993fb8e3695f37778bc6ca0a371 100644 (file)
@@ -40,7 +40,7 @@ def _real_extract(self, url):
             'https://v.redd.it/%s/DASHPlaylist.mpd' % video_id, video_id,
             mpd_id='dash', fatal=False))
 
-        self._sort_formats(formats, ('height', 'width'))
+        self._sort_formats(formats)
 
         return {
             'id': video_id,
index 9d9652949bb64ca2a15c02b3e0733dd9b7f42493..bc38a0f1e8a6ea2da8629c81d33d277c610264c7 100644 (file)
@@ -80,7 +80,9 @@ def _real_extract(self, url):
                     'format_id': '%s-%d' % (determine_protocol(f), tbr),
                     'tbr': tbr,
                 })
-            self._sort_formats(info_dict['formats'], ('tbr', 'height', 'width', 'format_id'))
+            # 'tbr' was explicitly set to be prefered over 'height' originally,
+            # So this is being kept unless someone can confirm this is unnecessary
+            self._sort_formats(info_dict['formats'], ('tbr', 'res'))
 
             thumbnails = []
             if video.get('thumbnailUrl'):
index 37cb8c839e5e1f37f80052fe9b6a306af663a9b0..f14bd6d712e240ccf36c605f7976de88124db19f 100644 (file)
@@ -129,7 +129,7 @@ def extract_format(format_id, format_url):
                     format_url = format_url[0]
                 extract_format(format_id, format_url)
 
-        self._sort_formats(formats, field_preference=('preference', 'height', 'width', 'fps', 'tbr', 'format_id'))
+        self._sort_formats(formats)
 
         info = self._search_json_ld(webpage, video_id, default={})
 
index 35ab9ec375989d412d94f7d40d2babadf93c44c4..e97c1d23e13f96fce330c976ac2d3ed3634a701f 100644 (file)
@@ -108,7 +108,7 @@ def _real_extract(self, url):
             formats.extend(self._extract_m3u8_formats(
                 m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',
                 m3u8_id='hls', fatal=False))
-        self._sort_formats(formats, ('height', 'tbr', 'width', 'format_id'))
+        self._sort_formats(formats)
 
         view_count = str_to_int(video.get('viewed'))
 
index f6d37bb9e0d847903eab4f9210757d41ce5cec70..71aa357df5449c3ae1543be9a18ccd9127f7dad2 100644 (file)
@@ -138,7 +138,10 @@ def _real_extract(self, url):
                 f['preference'] = -40
             elif f.get('vcodec') == 'none':
                 f['preference'] = -50
-        self._sort_formats(formats, ('preference', 'width', 'height', 'source_preference', 'tbr', 'vbr', 'abr', 'ext', 'format_id'))
+        # It seems like this would be correctly handled by default
+        # However, unless someone can confirm this, the old
+        # behaviour is being kept as-is
+        self._sort_formats(formats, ('res', 'source_preference'))
 
         subtitles = {}
         for subtitle in (config.get('subtitles') or []):
index 60e364d301feae058ae2eda4a7b46f7103ec3439..5b81aa365c6068913b92adcff1cb6a4796b4bcb8 100644 (file)
@@ -405,7 +405,7 @@ def extract_subtitles(track_list):
                 if f.get('url'):
                     formats.append(f)
 
-        self._sort_formats(formats, field_preference=('height', 'width', 'tbr', 'format_id'))
+        self._sort_formats(formats)
 
         return {
             'id': video_id,
index d815cd9a6babe0f3336677e0dd8149ab1661c7b7..8c84f2009e454e1a3091697815edf4ef6c122ffb 100644 (file)
@@ -91,7 +91,7 @@ def add_m3u8_format(format_id):
         if not formats:
             for format_id in (867, 836, 940):
                 add_m3u8_format(format_id)
-        self._sort_formats(formats, ('width', 'height', 'filesize', 'tbr'))
+        self._sort_formats(formats)
 
         return {
             'id': video_id,
index d6b92b1c833072bab2bbacb8503693b6da156427..55c2b95c2465d35b0ebc3520f7bc8c2c105848a5 100644 (file)
@@ -134,7 +134,7 @@ def _real_extract(self, url):
         if hls_url:
             formats.extend(self._extract_m3u8_formats(
                 hls_url, film_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
-        self._sort_formats(formats, ('height', 'tbr', 'format_id'))
+        self._sort_formats(formats)
 
         info = {
             'id': film_id,
index 299d99f6f9767d2508e096ee4edef34c4eaeb1dc..6004261972bc4e49d3a7be338ebeb58ce15d050d 100644 (file)
@@ -116,7 +116,8 @@ def _set_vimeo_cookie(self, name, value):
     def _vimeo_sort_formats(self, formats):
         # Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps
         # at the same time without actual units specified. This lead to wrong sorting.
-        self._sort_formats(formats, field_preference=('preference', 'height', 'width', 'fps', 'tbr', 'format_id'))
+        # But since yt-dlp prefers 'res,fps' anyway, 'field_preference' is not needed
+        self._sort_formats(formats)
 
     def _parse_config(self, config, video_id):
         video_data = config['video']
index f73b9778f6a9ffca618825b57fbf365955dc0ccb..1c93989868e7e8fd03dacc5011930f4610c647df 100644 (file)
@@ -231,7 +231,7 @@ def get_height(s):
                                         'Referer': standard_url,
                                     },
                                 })
-            self._sort_formats(formats, field_preference=('height', 'width', 'tbr', 'format_id'))
+            self._sort_formats(formats)
 
             categories_list = video.get('categories')
             if isinstance(categories_list, list):