[extractor] Deprecate `_sort_formats`

pull/5571/head
pukkandan 2 years ago
parent 784320c98c
commit 9f14daf22b
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39

@ -41,7 +41,9 @@ class InfoExtractorTestRequestHandler(http.server.BaseHTTPRequestHandler):
class DummyIE(InfoExtractor): class DummyIE(InfoExtractor):
pass def _sort_formats(self, formats, field_preference=[]):
self._downloader.sort_formats(
{'formats': formats, '_format_sort_fields': field_preference})
class TestInfoExtractor(unittest.TestCase): class TestInfoExtractor(unittest.TestCase):

@ -68,8 +68,7 @@ class TestFormatSelection(unittest.TestCase):
{'ext': 'mp4', 'height': 460, 'url': TEST_URL}, {'ext': 'mp4', 'height': 460, 'url': TEST_URL},
] ]
info_dict = _make_result(formats) info_dict = _make_result(formats)
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['ext'], 'webm') self.assertEqual(downloaded['ext'], 'webm')
@ -82,8 +81,7 @@ class TestFormatSelection(unittest.TestCase):
{'ext': 'mp4', 'height': 1080, 'url': TEST_URL}, {'ext': 'mp4', 'height': 1080, 'url': TEST_URL},
] ]
info_dict['formats'] = formats info_dict['formats'] = formats
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['ext'], 'mp4') self.assertEqual(downloaded['ext'], 'mp4')
@ -97,8 +95,7 @@ class TestFormatSelection(unittest.TestCase):
{'ext': 'flv', 'height': 720, 'url': TEST_URL}, {'ext': 'flv', 'height': 720, 'url': TEST_URL},
] ]
info_dict['formats'] = formats info_dict['formats'] = formats
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['ext'], 'mp4') self.assertEqual(downloaded['ext'], 'mp4')
@ -110,15 +107,14 @@ class TestFormatSelection(unittest.TestCase):
{'ext': 'webm', 'height': 720, 'url': TEST_URL}, {'ext': 'webm', 'height': 720, 'url': TEST_URL},
] ]
info_dict['formats'] = formats info_dict['formats'] = formats
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['ext'], 'webm') self.assertEqual(downloaded['ext'], 'webm')
def test_format_selection(self): def test_format_selection(self):
formats = [ formats = [
{'format_id': '35', 'ext': 'mp4', 'preference': 1, 'url': TEST_URL}, {'format_id': '35', 'ext': 'mp4', 'preference': 0, 'url': TEST_URL},
{'format_id': 'example-with-dashes', 'ext': 'webm', 'preference': 1, 'url': TEST_URL}, {'format_id': 'example-with-dashes', 'ext': 'webm', 'preference': 1, 'url': TEST_URL},
{'format_id': '45', 'ext': 'webm', 'preference': 2, 'url': TEST_URL}, {'format_id': '45', 'ext': 'webm', 'preference': 2, 'url': TEST_URL},
{'format_id': '47', 'ext': 'webm', 'preference': 3, 'url': TEST_URL}, {'format_id': '47', 'ext': 'webm', 'preference': 3, 'url': TEST_URL},
@ -186,22 +182,19 @@ class TestFormatSelection(unittest.TestCase):
info_dict = _make_result(formats) info_dict = _make_result(formats)
ydl = YDL({'format': 'best'}) ydl = YDL({'format': 'best'})
ie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
ie._sort_formats(info_dict['formats'])
ydl.process_ie_result(copy.deepcopy(info_dict)) ydl.process_ie_result(copy.deepcopy(info_dict))
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['format_id'], 'aac-64') self.assertEqual(downloaded['format_id'], 'aac-64')
ydl = YDL({'format': 'mp3'}) ydl = YDL({'format': 'mp3'})
ie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
ie._sort_formats(info_dict['formats'])
ydl.process_ie_result(copy.deepcopy(info_dict)) ydl.process_ie_result(copy.deepcopy(info_dict))
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['format_id'], 'mp3-64') self.assertEqual(downloaded['format_id'], 'mp3-64')
ydl = YDL({'prefer_free_formats': True}) ydl = YDL({'prefer_free_formats': True})
ie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
ie._sort_formats(info_dict['formats'])
ydl.process_ie_result(copy.deepcopy(info_dict)) ydl.process_ie_result(copy.deepcopy(info_dict))
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['format_id'], 'ogg-64') self.assertEqual(downloaded['format_id'], 'ogg-64')
@ -346,8 +339,7 @@ class TestFormatSelection(unittest.TestCase):
info_dict = _make_result(list(formats_order), extractor='youtube') info_dict = _make_result(list(formats_order), extractor='youtube')
ydl = YDL({'format': 'bestvideo+bestaudio'}) ydl = YDL({'format': 'bestvideo+bestaudio'})
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['format_id'], '248+172') self.assertEqual(downloaded['format_id'], '248+172')
@ -355,40 +347,35 @@ class TestFormatSelection(unittest.TestCase):
info_dict = _make_result(list(formats_order), extractor='youtube') info_dict = _make_result(list(formats_order), extractor='youtube')
ydl = YDL({'format': 'bestvideo[height>=999999]+bestaudio/best'}) ydl = YDL({'format': 'bestvideo[height>=999999]+bestaudio/best'})
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['format_id'], '38') self.assertEqual(downloaded['format_id'], '38')
info_dict = _make_result(list(formats_order), extractor='youtube') info_dict = _make_result(list(formats_order), extractor='youtube')
ydl = YDL({'format': 'bestvideo/best,bestaudio'}) ydl = YDL({'format': 'bestvideo/best,bestaudio'})
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded_ids = [info['format_id'] for info in ydl.downloaded_info_dicts] downloaded_ids = [info['format_id'] for info in ydl.downloaded_info_dicts]
self.assertEqual(downloaded_ids, ['137', '141']) self.assertEqual(downloaded_ids, ['137', '141'])
info_dict = _make_result(list(formats_order), extractor='youtube') info_dict = _make_result(list(formats_order), extractor='youtube')
ydl = YDL({'format': '(bestvideo[ext=mp4],bestvideo[ext=webm])+bestaudio'}) ydl = YDL({'format': '(bestvideo[ext=mp4],bestvideo[ext=webm])+bestaudio'})
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded_ids = [info['format_id'] for info in ydl.downloaded_info_dicts] downloaded_ids = [info['format_id'] for info in ydl.downloaded_info_dicts]
self.assertEqual(downloaded_ids, ['137+141', '248+141']) self.assertEqual(downloaded_ids, ['137+141', '248+141'])
info_dict = _make_result(list(formats_order), extractor='youtube') info_dict = _make_result(list(formats_order), extractor='youtube')
ydl = YDL({'format': '(bestvideo[ext=mp4],bestvideo[ext=webm])[height<=720]+bestaudio'}) ydl = YDL({'format': '(bestvideo[ext=mp4],bestvideo[ext=webm])[height<=720]+bestaudio'})
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded_ids = [info['format_id'] for info in ydl.downloaded_info_dicts] downloaded_ids = [info['format_id'] for info in ydl.downloaded_info_dicts]
self.assertEqual(downloaded_ids, ['136+141', '247+141']) self.assertEqual(downloaded_ids, ['136+141', '247+141'])
info_dict = _make_result(list(formats_order), extractor='youtube') info_dict = _make_result(list(formats_order), extractor='youtube')
ydl = YDL({'format': '(bestvideo[ext=none]/bestvideo[ext=webm])+bestaudio'}) ydl = YDL({'format': '(bestvideo[ext=none]/bestvideo[ext=webm])+bestaudio'})
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded_ids = [info['format_id'] for info in ydl.downloaded_info_dicts] downloaded_ids = [info['format_id'] for info in ydl.downloaded_info_dicts]
self.assertEqual(downloaded_ids, ['248+141']) self.assertEqual(downloaded_ids, ['248+141'])
@ -396,16 +383,14 @@ class TestFormatSelection(unittest.TestCase):
for f1, f2 in zip(formats_order, formats_order[1:]): for f1, f2 in zip(formats_order, formats_order[1:]):
info_dict = _make_result([f1, f2], extractor='youtube') info_dict = _make_result([f1, f2], extractor='youtube')
ydl = YDL({'format': 'best/bestvideo'}) ydl = YDL({'format': 'best/bestvideo'})
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['format_id'], f1['format_id']) self.assertEqual(downloaded['format_id'], f1['format_id'])
info_dict = _make_result([f2, f1], extractor='youtube') info_dict = _make_result([f2, f1], extractor='youtube')
ydl = YDL({'format': 'best/bestvideo'}) ydl = YDL({'format': 'best/bestvideo'})
yie = YoutubeIE(ydl) ydl.sort_formats(info_dict)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['format_id'], f1['format_id']) self.assertEqual(downloaded['format_id'], f1['format_id'])
@ -480,7 +465,7 @@ class TestFormatSelection(unittest.TestCase):
for f in formats: for f in formats:
f['url'] = 'http://_/' f['url'] = 'http://_/'
f['ext'] = 'unknown' f['ext'] = 'unknown'
info_dict = _make_result(formats) info_dict = _make_result(formats, _format_sort_fields=('id', ))
ydl = YDL({'format': 'best[filesize<3000]'}) ydl = YDL({'format': 'best[filesize<3000]'})
ydl.process_ie_result(info_dict) ydl.process_ie_result(info_dict)

@ -155,8 +155,6 @@ class ABCIE(InfoExtractor):
'format_id': format_id 'format_id': format_id
}) })
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': self._og_search_title(webpage), 'title': self._og_search_title(webpage),
@ -221,7 +219,6 @@ class ABCIViewIE(InfoExtractor):
entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
if formats: if formats:
break break
self._sort_formats(formats)
subtitles = {} subtitles = {}
src_vtt = stream.get('captions', {}).get('src-vtt') src_vtt = stream.get('captions', {}).get('src-vtt')

@ -78,7 +78,6 @@ class ABCOTVSIE(InfoExtractor):
'url': mp4_url, 'url': mp4_url,
'width': 640, 'width': 640,
}) })
self._sort_formats(formats)
image = video.get('image') or {} image = video.get('image') or {}
@ -119,7 +118,6 @@ class ABCOTVSClipsIE(InfoExtractor):
title = video_data['title'] title = video_data['title']
formats = self._extract_m3u8_formats( formats = self._extract_m3u8_formats(
video_data['videoURL'].split('?')[0], video_id, 'mp4') video_data['videoURL'].split('?')[0], video_id, 'mp4')
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -27,7 +27,6 @@ class AcFunVideoBaseIE(InfoExtractor):
**parse_codecs(video.get('codecs', '')) **parse_codecs(video.get('codecs', ''))
}) })
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'formats': formats, 'formats': formats,

@ -235,7 +235,6 @@ Format: Marked,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text'''
for f in m3u8_formats: for f in m3u8_formats:
f['language'] = 'fr' f['language'] = 'fr'
formats.extend(m3u8_formats) formats.extend(m3u8_formats)
self._sort_formats(formats)
video = (self._download_json( video = (self._download_json(
self._API_BASE_URL + 'video/%s' % video_id, video_id, self._API_BASE_URL + 'video/%s' % video_id, video_id,

@ -70,7 +70,6 @@ class AdobeTVBaseIE(InfoExtractor):
}) })
s3_extracted = True s3_extracted = True
formats.append(f) formats.append(f)
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
@ -269,7 +268,6 @@ class AdobeTVVideoIE(AdobeTVBaseIE):
'width': int_or_none(source.get('width') or None), 'width': int_or_none(source.get('width') or None),
'url': source_src, 'url': source_src,
}) })
self._sort_formats(formats)
# For both metadata and downloaded files the duration varies among # For both metadata and downloaded files the duration varies among
# formats. I just pick the max one # formats. I just pick the max one

@ -180,7 +180,6 @@ class AdultSwimIE(TurnerBaseIE):
info['subtitles'].setdefault('en', []).append({ info['subtitles'].setdefault('en', []).append({
'url': asset_url, 'url': asset_url,
}) })
self._sort_formats(info['formats'])
return info return info
else: else:

@ -62,7 +62,6 @@ class AENetworksBaseIE(ThePlatformIE): # XXX: Do not subclass from concrete IE
subtitles = self._merge_subtitles(subtitles, tp_subtitles) subtitles = self._merge_subtitles(subtitles, tp_subtitles)
if last_e and not formats: if last_e and not formats:
raise last_e raise last_e
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'formats': formats, 'formats': formats,

@ -338,7 +338,6 @@ class AfreecaTVIE(InfoExtractor):
}] }]
if not formats and not self.get_param('ignore_no_formats'): if not formats and not self.get_param('ignore_no_formats'):
continue continue
self._sort_formats(formats)
file_info = common_entry.copy() file_info = common_entry.copy()
file_info.update({ file_info.update({
'id': format_id, 'id': format_id,
@ -464,8 +463,6 @@ class AfreecaTVLiveIE(AfreecaTVIE): # XXX: Do not subclass from concrete IE
'quality': quality_key(quality_str), 'quality': quality_key(quality_str),
}) })
self._sort_formats(formats)
station_info = self._download_json( station_info = self._download_json(
'https://st.afreecatv.com/api/get_station_status.php', broadcast_no, 'https://st.afreecatv.com/api/get_station_status.php', broadcast_no,
query={'szBjId': broadcaster_id}, fatal=False, query={'szBjId': broadcaster_id}, fatal=False,

@ -55,7 +55,6 @@ class WyborczaVideoIE(InfoExtractor):
if meta['files'].get('dash'): if meta['files'].get('dash'):
formats.extend(self._extract_mpd_formats(base_url + meta['files']['dash'], video_id)) formats.extend(self._extract_mpd_formats(base_url + meta['files']['dash'], video_id))
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'formats': formats, 'formats': formats,
@ -179,7 +178,6 @@ class TokFMPodcastIE(InfoExtractor):
'acodec': ext, 'acodec': ext,
}) })
self._sort_formats(formats)
return { return {
'id': media_id, 'id': media_id,
'formats': formats, 'formats': formats,

@ -112,8 +112,6 @@ class AllocineIE(InfoExtractor):
}) })
duration, view_count, timestamp = [None] * 3 duration, view_count, timestamp = [None] * 3
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'display_id': display_id, 'display_id': display_id,

@ -22,7 +22,6 @@ class Alsace20TVBaseIE(InfoExtractor):
self._extract_smil_formats(fmt_url, video_id, fatal=False) self._extract_smil_formats(fmt_url, video_id, fatal=False)
if '/smil:_' in fmt_url if '/smil:_' in fmt_url
else self._extract_mpd_formats(fmt_url, video_id, mpd_id=res, fatal=False)) else self._extract_mpd_formats(fmt_url, video_id, mpd_id=res, fatal=False))
self._sort_formats(formats)
webpage = (url and self._download_webpage(url, video_id, fatal=False)) or '' webpage = (url and self._download_webpage(url, video_id, fatal=False)) or ''
thumbnail = url_or_none(dict_get(info, ('image', 'preview', )) or self._og_search_thumbnail(webpage)) thumbnail = url_or_none(dict_get(info, ('image', 'preview', )) or self._og_search_thumbnail(webpage))

@ -63,8 +63,6 @@ class AluraIE(InfoExtractor):
f['height'] = int('720' if m.group('res') == 'hd' else '480') f['height'] = int('720' if m.group('res') == 'hd' else '480')
formats.extend(video_format) formats.extend(video_format)
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': video_title, 'title': video_title,

@ -106,7 +106,6 @@ class AMCNetworksIE(ThePlatformIE): # XXX: Do not subclass from concrete IE
media_url = update_url_query(media_url, query) media_url = update_url_query(media_url, query)
formats, subtitles = self._extract_theplatform_smil( formats, subtitles = self._extract_theplatform_smil(
media_url, video_id) media_url, video_id)
self._sort_formats(formats)
thumbnails = [] thumbnails = []
thumbnail_urls = [properties.get('imageDesktop')] thumbnail_urls = [properties.get('imageDesktop')]

@ -84,8 +84,6 @@ class AMPIE(InfoExtractor): # XXX: Conventionally, base classes should end with
'ext': ext, 'ext': ext,
}) })
self._sort_formats(formats)
timestamp = unified_timestamp(item.get('pubDate'), ' ') or parse_iso8601(item.get('dc-date')) timestamp = unified_timestamp(item.get('pubDate'), ' ') or parse_iso8601(item.get('dc-date'))
return { return {

@ -19,7 +19,6 @@ class Ant1NewsGrBaseIE(InfoExtractor):
raise ExtractorError('no source found for %s' % video_id) raise ExtractorError('no source found for %s' % video_id)
formats, subs = (self._extract_m3u8_formats_and_subtitles(source, video_id, 'mp4') formats, subs = (self._extract_m3u8_formats_and_subtitles(source, video_id, 'mp4')
if determine_ext(source) == 'm3u8' else ([{'url': source}], {})) if determine_ext(source) == 'm3u8' else ([{'url': source}], {}))
self._sort_formats(formats)
thumbnails = scale_thumbnails_to_max_format_width( thumbnails = scale_thumbnails_to_max_format_width(
formats, [{'url': info['thumb']}], r'(?<=/imgHandler/)\d+') formats, [{'url': info['thumb']}], r'(?<=/imgHandler/)\d+')
return { return {

@ -354,8 +354,6 @@ class AnvatoIE(InfoExtractor):
}) })
formats.append(a_format) formats.append(a_format)
self._sort_formats(formats)
subtitles = {} subtitles = {}
for caption in video_data.get('captions', []): for caption in video_data.get('captions', []):
a_caption = { a_caption = {

@ -119,7 +119,6 @@ class AolIE(YahooIE): # XXX: Do not subclass from concrete IE
'height': int_or_none(qs.get('h', [None])[0]), 'height': int_or_none(qs.get('h', [None])[0]),
}) })
formats.append(f) formats.append(f)
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -72,7 +72,6 @@ class APAIE(InfoExtractor):
'format_id': format_id, 'format_id': format_id,
'height': height, 'height': height,
}) })
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -73,7 +73,6 @@ class AparatIE(InfoExtractor):
r'(\d+)[pP]', label or '', 'height', r'(\d+)[pP]', label or '', 'height',
default=None)), default=None)),
}) })
self._sort_formats(formats)
info = self._search_json_ld(webpage, video_id, default={}) info = self._search_json_ld(webpage, video_id, default={})

@ -120,7 +120,6 @@ class AppleTrailersIE(InfoExtractor):
'height': int_or_none(size_data.get('height')), 'height': int_or_none(size_data.get('height')),
'language': version[:2], 'language': version[:2],
}) })
self._sort_formats(formats)
entries.append({ entries.append({
'id': movie + '-' + re.sub(r'[^a-zA-Z0-9]', '', clip_title).lower(), 'id': movie + '-' + re.sub(r'[^a-zA-Z0-9]', '', clip_title).lower(),
@ -185,8 +184,6 @@ class AppleTrailersIE(InfoExtractor):
'height': int_or_none(format['height']), 'height': int_or_none(format['height']),
}) })
self._sort_formats(formats)
playlist.append({ playlist.append({
'_type': 'video', '_type': 'video',
'id': video_id, 'id': video_id,

@ -312,7 +312,7 @@ class ArchiveOrgIE(InfoExtractor):
}) })
for entry in entries.values(): for entry in entries.values():
self._sort_formats(entry['formats'], ('source', )) entry['_format_sort_fields'] = ('source', )
if len(entries) == 1: if len(entries) == 1:
# If there's only one item, use it as the main info dict # If there's only one item, use it as the main info dict

@ -144,7 +144,6 @@ class ArcPublishingIE(InfoExtractor):
'url': s_url, 'url': s_url,
'quality': -10, 'quality': -10,
}) })
self._sort_formats(formats)
subtitles = {} subtitles = {}
for subtitle in (try_get(video, lambda x: x['subtitles']['urls'], list) or []): for subtitle in (try_get(video, lambda x: x['subtitles']['urls'], list) or []):

@ -40,8 +40,6 @@ class ARDMediathekBaseIE(InfoExtractor):
'This video is not available due to geoblocking', 'This video is not available due to geoblocking',
countries=self._GEO_COUNTRIES, metadata_available=True) countries=self._GEO_COUNTRIES, metadata_available=True)
self._sort_formats(formats)
subtitles = {} subtitles = {}
subtitle_url = media_info.get('_subtitleUrl') subtitle_url = media_info.get('_subtitleUrl')
if subtitle_url: if subtitle_url:
@ -262,7 +260,6 @@ class ARDMediathekIE(ARDMediathekBaseIE):
'format_id': fid, 'format_id': fid,
'url': furl, 'url': furl,
}) })
self._sort_formats(formats)
info = { info = {
'formats': formats, 'formats': formats,
} }
@ -371,7 +368,6 @@ class ARDIE(InfoExtractor):
continue continue
f['url'] = format_url f['url'] = format_url
formats.append(f) formats.append(f)
self._sort_formats(formats)
_SUB_FORMATS = ( _SUB_FORMATS = (
('./dataTimedText', 'ttml'), ('./dataTimedText', 'ttml'),

@ -136,7 +136,6 @@ class ArkenaIE(InfoExtractor):
elif mime_type == 'application/vnd.ms-sstr+xml': elif mime_type == 'application/vnd.ms-sstr+xml':
formats.extend(self._extract_ism_formats( formats.extend(self._extract_ism_formats(
href, video_id, ism_id='mss', fatal=False)) href, video_id, ism_id='mss', fatal=False))
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -73,7 +73,6 @@ class ArnesIE(InfoExtractor):
'width': int_or_none(media.get('width')), 'width': int_or_none(media.get('width')),
'height': int_or_none(media.get('height')), 'height': int_or_none(media.get('height')),
}) })
self._sort_formats(formats)
channel = video.get('channel') or {} channel = video.get('channel') or {}
channel_id = channel.get('url') channel_id = channel.get('url')

@ -186,7 +186,6 @@ class ArteTVIE(ArteTVBaseIE):
formats.extend(secondary_formats) formats.extend(secondary_formats)
self._remove_duplicate_formats(formats) self._remove_duplicate_formats(formats)
self._sort_formats(formats)
metadata = config['data']['attributes']['metadata'] metadata = config['data']['attributes']['metadata']

@ -84,7 +84,6 @@ class AtresPlayerIE(InfoExtractor):
elif src_type == 'application/dash+xml': elif src_type == 'application/dash+xml':
formats, subtitles = self._extract_mpd_formats( formats, subtitles = self._extract_mpd_formats(
src, video_id, mpd_id='dash', fatal=False) src, video_id, mpd_id='dash', fatal=False)
self._sort_formats(formats)
heartbeat = episode.get('heartbeat') or {} heartbeat = episode.get('heartbeat') or {}
omniture = episode.get('omniture') or {} omniture = episode.get('omniture') or {}

@ -49,7 +49,6 @@ class ATVAtIE(InfoExtractor):
'url': source_url, 'url': source_url,
'format_id': protocol, 'format_id': protocol,
}) })
self._sort_formats(formats)
return { return {
'id': clip_id, 'id': clip_id,

@ -76,7 +76,6 @@ class AudiMediaIE(InfoExtractor):
'format_id': 'http-%s' % bitrate, 'format_id': 'http-%s' % bitrate,
}) })
formats.append(f) formats.append(f)
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -80,8 +80,6 @@ class BanByeIE(BanByeBaseIE):
'url': f'{self._CDN_BASE}/video/{video_id}/{quality}.mp4', 'url': f'{self._CDN_BASE}/video/{video_id}/{quality}.mp4',
} for quality in data['quality']] } for quality in data['quality']]
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': data.get('title'), 'title': data.get('title'),

@ -184,8 +184,6 @@ class BandcampIE(InfoExtractor):
'acodec': format_id.split('-')[0], 'acodec': format_id.split('-')[0],
}) })
self._sort_formats(formats)
title = '%s - %s' % (artist, track) if artist else track title = '%s - %s' % (artist, track) if artist else track
if not duration: if not duration:
@ -363,7 +361,6 @@ class BandcampWeeklyIE(BandcampIE): # XXX: Do not subclass from concrete IE
'ext': ext, 'ext': ext,
'vcodec': 'none', 'vcodec': 'none',
}) })
self._sort_formats(formats)
title = show.get('audio_title') or 'Bandcamp Weekly' title = show.get('audio_title') or 'Bandcamp Weekly'
subtitle = show.get('subtitle') subtitle = show.get('subtitle')

@ -135,7 +135,6 @@ query GetCommentReplies($id: String!) {
formats.extend(self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
video_info.get('streamUrl'), video_id, 'mp4', video_info.get('streamUrl'), video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls', live=True)) entry_protocol='m3u8_native', m3u8_id='hls', live=True))
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -575,8 +575,6 @@ class BBCCoUkIE(InfoExtractor):
else: else:
programme_id, title, description, duration, formats, subtitles = self._download_playlist(group_id) programme_id, title, description, duration, formats, subtitles = self._download_playlist(group_id)
self._sort_formats(formats)
return { return {
'id': programme_id, 'id': programme_id,
'title': title, 'title': title,
@ -890,7 +888,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
def _extract_from_playlist_sxml(self, url, playlist_id, timestamp): def _extract_from_playlist_sxml(self, url, playlist_id, timestamp):
programme_id, title, description, duration, formats, subtitles = \ programme_id, title, description, duration, formats, subtitles = \
self._process_legacy_playlist_url(url, playlist_id) self._process_legacy_playlist_url(url, playlist_id)
self._sort_formats(formats)
return { return {
'id': programme_id, 'id': programme_id,
'title': title, 'title': title,
@ -954,7 +951,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
duration = int_or_none(items[0].get('duration')) duration = int_or_none(items[0].get('duration'))
programme_id = items[0].get('vpid') programme_id = items[0].get('vpid')
formats, subtitles = self._download_media_selector(programme_id) formats, subtitles = self._download_media_selector(programme_id)
self._sort_formats(formats)
entries.append({ entries.append({
'id': programme_id, 'id': programme_id,
'title': title, 'title': title,
@ -991,7 +987,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
continue continue
raise raise
if entry: if entry:
self._sort_formats(entry['formats'])
entries.append(entry) entries.append(entry)
if entries: if entries:
@ -1015,7 +1010,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
if programme_id: if programme_id:
formats, subtitles = self._download_media_selector(programme_id) formats, subtitles = self._download_media_selector(programme_id)
self._sort_formats(formats)
# digitalData may be missing (e.g. http://www.bbc.com/autos/story/20130513-hyundais-rock-star) # digitalData may be missing (e.g. http://www.bbc.com/autos/story/20130513-hyundais-rock-star)
digital_data = self._parse_json( digital_data = self._parse_json(
self._search_regex( self._search_regex(
@ -1047,7 +1041,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
if version_id: if version_id:
title = smp_data['title'] title = smp_data['title']
formats, subtitles = self._download_media_selector(version_id) formats, subtitles = self._download_media_selector(version_id)
self._sort_formats(formats)
image_url = smp_data.get('holdingImageURL') image_url = smp_data.get('holdingImageURL')
display_date = init_data.get('displayDate') display_date = init_data.get('displayDate')
topic_title = init_data.get('topicTitle') topic_title = init_data.get('topicTitle')
@ -1089,7 +1082,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
continue continue
title = lead_media.get('title') or self._og_search_title(webpage) title = lead_media.get('title') or self._og_search_title(webpage)
formats, subtitles = self._download_media_selector(programme_id) formats, subtitles = self._download_media_selector(programme_id)
self._sort_formats(formats)
description = lead_media.get('summary') description = lead_media.get('summary')
uploader = lead_media.get('masterBrand') uploader = lead_media.get('masterBrand')
uploader_id = lead_media.get('mid') uploader_id = lead_media.get('mid')
@ -1118,7 +1110,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
if current_programme and programme_id and current_programme.get('type') == 'playable_item': if current_programme and programme_id and current_programme.get('type') == 'playable_item':
title = current_programme.get('titles', {}).get('tertiary') or playlist_title title = current_programme.get('titles', {}).get('tertiary') or playlist_title
formats, subtitles = self._download_media_selector(programme_id) formats, subtitles = self._download_media_selector(programme_id)
self._sort_formats(formats)
synopses = current_programme.get('synopses') or {} synopses = current_programme.get('synopses') or {}
network = current_programme.get('network') or {} network = current_programme.get('network') or {}
duration = int_or_none( duration = int_or_none(
@ -1151,7 +1142,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
clip_title = clip.get('title') clip_title = clip.get('title')
if clip_vpid and clip_title: if clip_vpid and clip_title:
formats, subtitles = self._download_media_selector(clip_vpid) formats, subtitles = self._download_media_selector(clip_vpid)
self._sort_formats(formats)
return { return {
'id': clip_vpid, 'id': clip_vpid,
'title': clip_title, 'title': clip_title,
@ -1173,7 +1163,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
if not programme_id: if not programme_id:
continue continue
formats, subtitles = self._download_media_selector(programme_id) formats, subtitles = self._download_media_selector(programme_id)
self._sort_formats(formats)
entries.append({ entries.append({
'id': programme_id, 'id': programme_id,
'title': playlist_title, 'title': playlist_title,
@ -1205,7 +1194,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
if not (item_id and item_title): if not (item_id and item_title):
continue continue
formats, subtitles = self._download_media_selector(item_id) formats, subtitles = self._download_media_selector(item_id)
self._sort_formats(formats)
item_desc = None item_desc = None
blocks = try_get(media, lambda x: x['summary']['blocks'], list) blocks = try_get(media, lambda x: x['summary']['blocks'], list)
if blocks: if blocks:
@ -1306,7 +1294,6 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
formats, subtitles = self._extract_from_media_meta(media_meta, playlist_id) formats, subtitles = self._extract_from_media_meta(media_meta, playlist_id)
if not formats and not self.get_param('ignore_no_formats'): if not formats and not self.get_param('ignore_no_formats'):
continue continue
self._sort_formats(formats)
video_id = media_meta.get('externalId') video_id = media_meta.get('externalId')
if not video_id: if not video_id:

@ -74,7 +74,6 @@ class BeatportIE(InfoExtractor):
fmt['abr'] = 96 fmt['abr'] = 96
fmt['asr'] = 44100 fmt['asr'] = 44100
formats.append(fmt) formats.append(fmt)
self._sort_formats(formats)
images = [] images = []
for name, info in track['images'].items(): for name, info in track['images'].items():

@ -76,8 +76,6 @@ class BeegIE(InfoExtractor):
f['height'] = height f['height'] = height
formats.extend(current_formats) formats.extend(current_formats)
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'display_id': first_fact.get('id'), 'display_id': first_fact.get('id'),

@ -63,8 +63,6 @@ class BigflixIE(InfoExtractor):
'url': decode_url(file_url), 'url': decode_url(file_url),
}) })
self._sort_formats(formats)
description = self._html_search_meta('description', webpage) description = self._html_search_meta('description', webpage)
return { return {

@ -67,7 +67,6 @@ class BilibiliBaseIE(InfoExtractor):
self.to_screen(f'Format(s) {", ".join(format_names[i] for i in missing_formats)} are missing; ' self.to_screen(f'Format(s) {", ".join(format_names[i] for i in missing_formats)} are missing; '
f'you have to login or become premium member to download them. {self._login_hint()}') f'you have to login or become premium member to download them. {self._login_hint()}')
self._sort_formats(formats)
return formats return formats
def json2srt(self, json_data): def json2srt(self, json_data):
@ -879,7 +878,6 @@ class BiliIntlBaseIE(InfoExtractor):
'filesize': aud.get('size'), 'filesize': aud.get('size'),
}) })
self._sort_formats(formats)
return formats return formats
def _extract_video_info(self, video_data, *, ep_id=None, aid=None): def _extract_video_info(self, video_data, *, ep_id=None, aid=None):
@ -1105,7 +1103,6 @@ class BiliLiveIE(InfoExtractor):
}) })
for fmt in traverse_obj(stream_data, ('playurl_info', 'playurl', 'stream', ..., 'format', ...)) or []: for fmt in traverse_obj(stream_data, ('playurl_info', 'playurl', 'stream', ..., 'format', ...)) or []:
formats.extend(self._parse_formats(qn, fmt)) formats.extend(self._parse_formats(qn, fmt))
self._sort_formats(formats)
return { return {
'id': room_id, 'id': room_id,

@ -86,7 +86,6 @@ class BIQLEIE(InfoExtractor):
'height': int_or_none(height), 'height': int_or_none(height),
'ext': ext, 'ext': ext,
}) })
self._sort_formats(formats)
thumbnails = [] thumbnails = []
for k, v in item.items(): for k, v in item.items():

@ -117,7 +117,6 @@ class BitChuteIE(InfoExtractor):
self.raise_no_formats( self.raise_no_formats(
'Video is unavailable. Please make sure this video is playable in the browser ' 'Video is unavailable. Please make sure this video is playable in the browser '
'before reporting this issue.', expected=True, video_id=video_id) 'before reporting this issue.', expected=True, video_id=video_id)
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -45,7 +45,6 @@ class BitwaveStreamIE(InfoExtractor):
formats = self._extract_m3u8_formats( formats = self._extract_m3u8_formats(
channel['data']['url'], username, channel['data']['url'], username,
'mp4') 'mp4')
self._sort_formats(formats)
return { return {
'id': username, 'id': username,

@ -67,7 +67,6 @@ class BloombergIE(InfoExtractor):
else: else:
formats.extend(self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
stream_url, video_id, f4m_id='hds', fatal=False)) stream_url, video_id, f4m_id='hds', fatal=False))
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -21,8 +21,6 @@ class BokeCCBaseIE(InfoExtractor):
'quality': int(quality.attrib['value']), 'quality': int(quality.attrib['value']),
} for quality in info_xml.findall('./video/quality')] } for quality in info_xml.findall('./video/quality')]
self._sort_formats(formats)
return formats return formats

@ -57,7 +57,6 @@ class BongaCamsIE(InfoExtractor):
formats = self._extract_m3u8_formats( formats = self._extract_m3u8_formats(
'%s/hls/stream_%s/playlist.m3u8' % (server_url, uploader_id), '%s/hls/stream_%s/playlist.m3u8' % (server_url, uploader_id),
channel_id, 'mp4', m3u8_id='hls', live=True) channel_id, 'mp4', m3u8_id='hls', live=True)
self._sort_formats(formats)
return { return {
'id': channel_id, 'id': channel_id,

@ -67,7 +67,6 @@ class BooyahClipsIE(BooyahBaseIE):
'height': video_data.get('resolution'), 'height': video_data.get('resolution'),
'preference': -10, 'preference': -10,
})) }))
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -79,8 +79,6 @@ class BoxIE(InfoExtractor):
'url': update_url_query(authenticated_download_url, query), 'url': update_url_query(authenticated_download_url, query),
}) })
self._sort_formats(formats)
creator = f.get('created_by') or {} creator = f.get('created_by') or {}
return { return {

@ -48,8 +48,6 @@ class BpbIE(InfoExtractor):
'format_id': '%s-%s' % (quality, determine_ext(video_url)), 'format_id': '%s-%s' % (quality, determine_ext(video_url)),
}) })
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'formats': formats, 'formats': formats,

@ -157,7 +157,6 @@ class BRIE(InfoExtractor):
'format_id': 'rtmp-%s' % asset_type, 'format_id': 'rtmp-%s' % asset_type,
}) })
formats.append(rtmp_format_info) formats.append(rtmp_format_info)
self._sort_formats(formats)
return formats return formats
def _extract_thumbnails(self, variants, base_url): def _extract_thumbnails(self, variants, base_url):
@ -272,7 +271,6 @@ class BRMediathekIE(InfoExtractor):
'tbr': tbr, 'tbr': tbr,
'filesize': int_or_none(node.get('fileSize')), 'filesize': int_or_none(node.get('fileSize')),
}) })
self._sort_formats(formats)
subtitles = {} subtitles = {}
for edge in clip.get('captionFiles', {}).get('edges', []): for edge in clip.get('captionFiles', {}).get('edges', []):

@ -63,7 +63,6 @@ class BreakIE(InfoExtractor):
'format_id': 'http-%d' % bitrate if bitrate else 'http', 'format_id': 'http-%d' % bitrate if bitrate else 'http',
'tbr': bitrate, 'tbr': bitrate,
}) })
self._sort_formats(formats)
title = self._search_regex( title = self._search_regex(
(r'title["\']\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1', (r'title["\']\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1',

@ -24,7 +24,6 @@ class BreitBartIE(InfoExtractor):
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
formats = self._extract_m3u8_formats(f'https://cdn.jwplayer.com/manifests/{video_id}.m3u8', video_id, ext='mp4') formats = self._extract_m3u8_formats(f'https://cdn.jwplayer.com/manifests/{video_id}.m3u8', video_id, ext='mp4')
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': self._generic_title('', webpage), 'title': self._generic_title('', webpage),

@ -546,8 +546,6 @@ class BrightcoveNewIE(AdobePassIE):
self.raise_no_formats( self.raise_no_formats(
error.get('message') or error.get('error_subcode') or error['error_code'], expected=True) error.get('message') or error.get('error_subcode') or error['error_code'], expected=True)
self._sort_formats(formats)
for f in formats: for f in formats:
f.setdefault('http_headers', {}).update(headers) f.setdefault('http_headers', {}).update(headers)

@ -108,7 +108,6 @@ class BYUtvIE(InfoExtractor):
'thumbnail': ep.get('imageThumbnail'), 'thumbnail': ep.get('imageThumbnail'),
'duration': parse_duration(ep.get('length')), 'duration': parse_duration(ep.get('length')),
}) })
self._sort_formats(formats)
return merge_dicts(info, { return merge_dicts(info, {
'id': video_id, 'id': video_id,

@ -49,7 +49,6 @@ class C56IE(InfoExtractor):
'url': f['url'] 'url': f['url']
} for f in info['rfiles'] } for f in info['rfiles']
] ]
self._sort_formats(formats)
return { return {
'id': info['vid'], 'id': info['vid'],

@ -22,7 +22,6 @@ class CableAVIE(InfoExtractor):
video_url = self._og_search_video_url(webpage, secure=False) video_url = self._og_search_video_url(webpage, secure=False)
formats = self._extract_m3u8_formats(video_url, video_id, 'mp4') formats = self._extract_m3u8_formats(video_url, video_id, 'mp4')
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -54,7 +54,6 @@ class CallinIE(InfoExtractor):
title = episode.get('title') or self._generic_title('', webpage) title = episode.get('title') or self._generic_title('', webpage)
url = episode['m3u8'] url = episode['m3u8']
formats = self._extract_m3u8_formats(url, display_id, ext='ts') formats = self._extract_m3u8_formats(url, display_id, ext='ts')
self._sort_formats(formats)
show = traverse_obj(episode, ('show', 'title')) show = traverse_obj(episode, ('show', 'title'))
show_id = traverse_obj(episode, ('show', 'id')) show_id = traverse_obj(episode, ('show', 'id'))

@ -27,7 +27,6 @@ class CaltransIE(InfoExtractor):
video_stream = self._search_regex(r'videoStreamURL\s*=\s*"([^"]+)"', global_vars, 'Video Stream URL', fatal=False) video_stream = self._search_regex(r'videoStreamURL\s*=\s*"([^"]+)"', global_vars, 'Video Stream URL', fatal=False)
formats = self._extract_m3u8_formats(video_stream, video_id, 'ts', live=True) formats = self._extract_m3u8_formats(video_stream, video_id, 'ts', live=True)
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -20,7 +20,6 @@ class CAM4IE(InfoExtractor):
m3u8_playlist = self._download_json('https://www.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(channel_id), channel_id).get('cdnURL') m3u8_playlist = self._download_json('https://www.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(channel_id), channel_id).get('cdnURL')
formats = self._extract_m3u8_formats(m3u8_playlist, channel_id, 'mp4', m3u8_id='hls', live=True) formats = self._extract_m3u8_formats(m3u8_playlist, channel_id, 'mp4', m3u8_id='hls', live=True)
self._sort_formats(formats)
return { return {
'id': channel_id, 'id': channel_id,

@ -84,7 +84,6 @@ class CamModelsIE(InfoExtractor):
else: else:
continue continue
formats.append(f) formats.append(f)
self._sort_formats(formats)
return { return {
'id': user_id, 'id': user_id,

@ -47,8 +47,6 @@ class CamsodaIE(InfoExtractor):
if not formats: if not formats:
self.raise_no_formats('No active streams found', expected=True) self.raise_no_formats('No active streams found', expected=True)
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': self._html_extract_title(webpage), 'title': self._html_extract_title(webpage),

@ -82,7 +82,6 @@ class CanalAlphaIE(InfoExtractor):
dash_frmts, dash_subs = self._parse_mpd_formats_and_subtitles(manifests['dash']) dash_frmts, dash_subs = self._parse_mpd_formats_and_subtitles(manifests['dash'])
formats.extend(dash_frmts) formats.extend(dash_frmts)
subtitles = self._merge_subtitles(subtitles, dash_subs) subtitles = self._merge_subtitles(subtitles, dash_subs)
self._sort_formats(formats)
return { return {
'id': id, 'id': id,
'title': data_json.get('title').strip(), 'title': data_json.get('title').strip(),

@ -58,8 +58,6 @@ class Canalc2IE(InfoExtractor):
else: else:
info = self._parse_html5_media_entries(url, webpage, url)[0] info = self._parse_html5_media_entries(url, webpage, url)[0]
self._sort_formats(info['formats'])
info.update({ info.update({
'id': video_id, 'id': video_id,
'title': title, 'title': title,

@ -86,7 +86,6 @@ class CanalplusIE(InfoExtractor):
'format_id': format_id, 'format_id': format_id,
'quality': preference(format_id), 'quality': preference(format_id),
}) })
self._sort_formats(formats)
thumbnails = [{ thumbnails = [{
'id': image_id, 'id': image_id,

@ -118,7 +118,6 @@ class CanvasIE(InfoExtractor):
'format_id': format_type, 'format_id': format_type,
'url': format_url, 'url': format_url,
}) })
self._sort_formats(formats)
subtitle_urls = data.get('subtitleUrls') subtitle_urls = data.get('subtitleUrls')
if isinstance(subtitle_urls, list): if isinstance(subtitle_urls, list):

@ -43,7 +43,6 @@ class CarambaTVIE(InfoExtractor):
'height': int_or_none(f.get('height')), 'height': int_or_none(f.get('height')),
'format_id': format_field(f, 'height', '%sp'), 'format_id': format_field(f, 'height', '%sp'),
} for f in video['qualities'] if f.get('fn')] } for f in video['qualities'] if f.get('fn')]
self._sort_formats(formats)
thumbnail = video.get('splash') thumbnail = video.get('splash')
duration = float_or_none(try_get( duration = float_or_none(try_get(

@ -380,8 +380,6 @@ class CBCGemIE(InfoExtractor):
if 'descriptive' in format['format_id'].lower(): if 'descriptive' in format['format_id'].lower():
format['preference'] = -2 format['preference'] = -2
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': video_info['title'], 'title': video_info['title'],

@ -52,7 +52,6 @@ class CBSBaseIE(ThePlatformFeedIE): # XXX: Do not subclass from concrete IE
subtitles = self._merge_subtitles(subtitles, tp_subtitles) subtitles = self._merge_subtitles(subtitles, tp_subtitles)
if last_e and not formats: if last_e and not formats:
self.raise_no_formats(last_e, True, content_id) self.raise_no_formats(last_e, True, content_id)
self._sort_formats(formats)
extra_info.update({ extra_info.update({
'id': content_id, 'id': content_id,

@ -132,7 +132,6 @@ class CBSNewsLiveVideoIE(InfoExtractor):
}) })
formats = self._extract_akamai_formats(video_info['url'], display_id) formats = self._extract_akamai_formats(video_info['url'], display_id)
self._sort_formats(formats)
return { return {
'id': display_id, 'id': display_id,

@ -40,7 +40,6 @@ class CBSSportsEmbedIE(InfoExtractor):
formats = self._extract_m3u8_formats( formats = self._extract_m3u8_formats(
metadata['files'][0]['url'], video_id, 'mp4', metadata['files'][0]['url'], video_id, 'mp4',
'm3u8_native', m3u8_id='hls', fatal=False) 'm3u8_native', m3u8_id='hls', fatal=False)
self._sort_formats(formats)
image = video.get('image') image = video.get('image')
thumbnails = None thumbnails = None

@ -64,7 +64,6 @@ class CCCIE(InfoExtractor):
'language': language, 'language': language,
'vcodec': vcodec, 'vcodec': vcodec,
}) })
self._sort_formats(formats)
return { return {
'id': event_id, 'id': event_id,

@ -81,7 +81,6 @@ class CCMAIE(InfoExtractor):
'url': media_url, 'url': media_url,
'vcodec': 'none' if media_type == 'audio' else None, 'vcodec': 'none' if media_type == 'audio' else None,
}) })
self._sort_formats(formats)
informacio = media['informacio'] informacio = media['informacio']
title = informacio['titol'] title = informacio['titol']

@ -170,8 +170,6 @@ class CCTVIE(InfoExtractor):
hls_url, video_id, 'mp4', entry_protocol='m3u8_native', hls_url, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls', fatal=False)) m3u8_id='hls', fatal=False))
self._sort_formats(formats)
uploader = data.get('editer_name') uploader = data.get('editer_name')
description = self._html_search_meta( description = self._html_search_meta(
'description', webpage, default=None) 'description', webpage, default=None)

@ -151,8 +151,6 @@ class CDAIE(InfoExtractor):
'filesize': quality.get('length'), 'filesize': quality.get('length'),
} for quality in meta['qualities'] if quality.get('file')] } for quality in meta['qualities'] if quality.get('file')]
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': meta.get('title'), 'title': meta.get('title'),
@ -304,6 +302,4 @@ class CDAIE(InfoExtractor):
extract_format(webpage, resolution) extract_format(webpage, resolution)
self._sort_formats(formats)
return merge_dicts(info_dict, info) return merge_dicts(info_dict, info)

@ -50,7 +50,6 @@ class CellebriteIE(InfoExtractor):
f'https://play.vidyard.com/player/{player_uuid}.json', display_id)['payload']['chapters'][0] f'https://play.vidyard.com/player/{player_uuid}.json', display_id)['payload']['chapters'][0]
formats, subtitles = self._get_formats_and_subtitles(json_data['sources'], display_id) formats, subtitles = self._get_formats_and_subtitles(json_data['sources'], display_id)
self._sort_formats(formats)
return { return {
'id': str(json_data['videoId']), 'id': str(json_data['videoId']),
'title': json_data.get('name') or self._og_search_title(webpage), 'title': json_data.get('name') or self._og_search_title(webpage),

@ -249,9 +249,6 @@ class CeskaTelevizeIE(InfoExtractor):
'is_live': is_live, 'is_live': is_live,
}) })
for e in entries:
self._sort_formats(e['formats'])
if len(entries) == 1: if len(entries) == 1:
return entries[0] return entries[0]
return self.playlist_result(entries, playlist_id, playlist_title, playlist_description) return self.playlist_result(entries, playlist_id, playlist_title, playlist_description)

@ -185,7 +185,6 @@ class Channel9IE(InfoExtractor):
if not formats and not slides and not zip_file: if not formats and not slides and not zip_file:
self.raise_no_formats( self.raise_no_formats(
'None of recording, slides or zip are available for %s' % content_path) 'None of recording, slides or zip are available for %s' % content_path)
self._sort_formats(formats)
subtitles = {} subtitles = {}
for caption in content_data.get('Captions', []): for caption in content_data.get('Captions', []):

@ -38,8 +38,6 @@ class CharlieRoseIE(InfoExtractor):
info_dict = self._parse_html5_media_entries( info_dict = self._parse_html5_media_entries(
self._PLAYER_BASE % video_id, webpage, video_id, self._PLAYER_BASE % video_id, webpage, video_id,
m3u8_entry_protocol='m3u8_native')[0] m3u8_entry_protocol='m3u8_native')[0]
self._sort_formats(info_dict['formats'])
self._remove_duplicate_formats(info_dict['formats']) self._remove_duplicate_formats(info_dict['formats'])
info_dict.update({ info_dict.update({

@ -95,7 +95,6 @@ class ChaturbateIE(InfoExtractor):
# ffmpeg skips segments for fast m3u8 # ffmpeg skips segments for fast m3u8
preference=-10 if m3u8_id == 'fast' else None, preference=-10 if m3u8_id == 'fast' else None,
m3u8_id=m3u8_id, fatal=False, live=True)) m3u8_id=m3u8_id, fatal=False, live=True))
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -32,7 +32,6 @@ class ChingariBaseIE(InfoExtractor):
'url': base_url + '/apipublic' + media_data['path'], 'url': base_url + '/apipublic' + media_data['path'],
'quality': 10, 'quality': 10,
}) })
self._sort_formats(formats)
timestamp = str_to_int(post_data.get('created_at')) timestamp = str_to_int(post_data.get('created_at'))
if timestamp: if timestamp:
timestamp = int_or_none(timestamp, 1000) timestamp = int_or_none(timestamp, 1000)

@ -47,7 +47,6 @@ class CinchcastIE(InfoExtractor):
'format_id': 'backup', 'format_id': 'backup',
'url': backup_url, 'url': backup_url,
}) })
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -72,7 +72,6 @@ class CiscoWebexIE(InfoExtractor):
'vcodec': 'none', 'vcodec': 'none',
'acodec': 'mp3', 'acodec': 'mp3',
}) })
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -62,7 +62,6 @@ class CliphunterIE(InfoExtractor):
'height': int_or_none(height), 'height': int_or_none(height),
'tbr': int_or_none(f.get('br')), 'tbr': int_or_none(f.get('br')),
}) })
self._sort_formats(formats)
thumbnail = self._search_regex( thumbnail = self._search_regex(
r"var\s+mov_thumb\s*=\s*'([^']+)';", r"var\s+mov_thumb\s*=\s*'([^']+)';",

@ -51,7 +51,6 @@ class CloudflareStreamIE(InfoExtractor):
'm3u8_native', m3u8_id='hls', fatal=False) 'm3u8_native', m3u8_id='hls', fatal=False)
formats.extend(self._extract_mpd_formats( formats.extend(self._extract_mpd_formats(
manifest_base_url + 'mpd', video_id, mpd_id='dash', fatal=False)) manifest_base_url + 'mpd', video_id, mpd_id='dash', fatal=False))
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -42,7 +42,6 @@ class ClubicIE(InfoExtractor):
'url': src['src'], 'url': src['src'],
'quality': quality_order(src['streamQuality']), 'quality': quality_order(src['streamQuality']),
} for src in sources] } for src in sources]
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -60,7 +60,6 @@ class ClypIE(InfoExtractor):
'format_id': format_id, 'format_id': format_id,
'vcodec': 'none', 'vcodec': 'none',
}) })
self._sort_formats(formats)
title = metadata['Title'] title = metadata['Title']
description = metadata.get('Description') description = metadata.get('Description')

@ -1699,7 +1699,14 @@ class InfoExtractor:
return FormatSort return FormatSort
def _sort_formats(self, formats, field_preference=[]): 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 formats[0]['__sort_fields'] = field_preference
def _check_formats(self, formats, video_id): def _check_formats(self, formats, video_id):
@ -2431,7 +2438,6 @@ class InfoExtractor:
'width': int_or_none(location.get(xpath_with_ns('s1:width', NS_MAP))), '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))), 'height': int_or_none(location.get(xpath_with_ns('s1:height', NS_MAP))),
}) })
self._sort_formats(formats)
entries.append({ entries.append({
'id': playlist_id, 'id': playlist_id,
@ -3269,7 +3275,6 @@ class InfoExtractor:
'url': formats[0]['url'], 'url': formats[0]['url'],
}) })
else: else:
self._sort_formats(formats)
entry['formats'] = formats entry['formats'] = formats
entries.append(entry) entries.append(entry)
if len(entries) == 1: if len(entries) == 1:

@ -197,7 +197,6 @@ class CondeNastIE(InfoExtractor):
'ext': ext, 'ext': ext,
'quality': 1 if quality == 'high' else 0, 'quality': 1 if quality == 'high' else 0,
}) })
self._sort_formats(formats)
subtitles = {} subtitles = {}
for t, caption in video_info.get('captions', {}).items(): for t, caption in video_info.get('captions', {}).items():

@ -69,8 +69,6 @@ class CONtvIE(InfoExtractor):
'url': media_mp4_url, 'url': media_mp4_url,
}) })
self._sort_formats(formats)
subtitles = {} subtitles = {}
captions = m_details.get('captions') or {} captions = m_details.get('captions') or {}
for caption_url in captions.values(): for caption_url in captions.values():

@ -126,7 +126,6 @@ class CorusIE(ThePlatformFeedIE): # XXX: Do not subclass from concrete IE
smil, smil_url, video_id, namespace)) smil, smil_url, video_id, namespace))
if not formats and video.get('drm'): if not formats and video.get('drm'):
self.report_drm(video_id) self.report_drm(video_id)
self._sort_formats(formats)
subtitles = {} subtitles = {}
for track in video.get('tracks', []): for track in video.get('tracks', []):

@ -104,8 +104,6 @@ class CoubIE(InfoExtractor):
'source_preference': preference_key(MOBILE), 'source_preference': preference_key(MOBILE),
}) })
self._sort_formats(formats)
thumbnail = coub.get('picture') thumbnail = coub.get('picture')
duration = float_or_none(coub.get('duration')) duration = float_or_none(coub.get('duration'))
timestamp = parse_iso8601(coub.get('published_at') or coub.get('created_at')) timestamp = parse_iso8601(coub.get('published_at') or coub.get('created_at'))

@ -54,8 +54,6 @@ class CPACIE(InfoExtractor):
else: else:
fmt['language_preference'] = -10 fmt['language_preference'] = -10
self._sort_formats(formats)
category = str_or_none(content['details']['category_%s_t' % (url_lang, )]) category = str_or_none(content['details']['category_%s_t' % (url_lang, )])
def is_live(v_type): def is_live(v_type):

@ -177,7 +177,6 @@ class CrackleIE(InfoExtractor):
}) })
if not formats and has_drm: if not formats and has_drm:
self.report_drm(video_id) self.report_drm(video_id)
self._sort_formats(formats)
description = media.get('Description') description = media.get('Description')
duration = int_or_none(media.get( duration = int_or_none(media.get(

@ -45,7 +45,6 @@ class CrooksAndLiarsIE(InfoExtractor):
'format_id': item['type'], 'format_id': item['type'],
'quality': quality(item['type']), 'quality': quality(item['type']),
} for item in manifest['flavors'] if item['mime'].startswith('video/')] } for item in manifest['flavors'] if item['mime'].startswith('video/')]
self._sort_formats(formats)
return { return {
'url': url, 'url': url,

@ -60,7 +60,6 @@ class CrowdBunkerIE(InfoExtractor):
'width': int_or_none(image.get('width')), 'width': int_or_none(image.get('width')),
} for image in video_json.get('thumbnails') or [] if image.get('url')] } for image in video_json.get('thumbnails') or [] if image.get('url')]
self._sort_formats(formats)
return { return {
'id': id, 'id': id,
'title': video_json.get('title'), 'title': video_json.get('title'),

@ -208,7 +208,6 @@ class CrunchyrollBetaIE(CrunchyrollBaseIE):
f['language'] = stream_response.get('audio_locale') f['language'] = stream_response.get('audio_locale')
f['quality'] = hardsub_preference(hardsub_lang.lower()) f['quality'] = hardsub_preference(hardsub_lang.lower())
formats.extend(adaptive_formats) formats.extend(adaptive_formats)
self._sort_formats(formats)
return { return {
'id': internal_id, 'id': internal_id,

@ -218,7 +218,6 @@ class CSpanIE(InfoExtractor):
path, video_id, 'mp4', entry_protocol='m3u8_native', path, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls') if determine_ext(path) == 'm3u8' else [{'url': path, }] m3u8_id='hls') if determine_ext(path) == 'm3u8' else [{'url': path, }]
add_referer(formats) add_referer(formats)
self._sort_formats(formats)
entries.append({ entries.append({
'id': '%s_%d' % (video_id, partnum + 1), 'id': '%s_%d' % (video_id, partnum + 1),
'title': ( 'title': (

@ -117,7 +117,6 @@ class CuriosityStreamIE(CuriosityStreamBaseIE):
'format_id': 'http', 'format_id': 'http',
}) })
formats.append(fmt) formats.append(fmt)
self._sort_formats(formats)
title = media['title'] title = media['title']

@ -81,7 +81,6 @@ class DaftsexIE(InfoExtractor):
'height': int_or_none(height), 'height': int_or_none(height),
'ext': ext, 'ext': ext,
}) })
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
@ -117,7 +116,6 @@ class DaftsexIE(InfoExtractor):
'height': int_or_none(height), 'height': int_or_none(height),
'ext': ext, 'ext': ext,
}) })
self._sort_formats(formats)
thumbnails = [] thumbnails = []
for k, v in item.items(): for k, v in item.items():

@ -63,7 +63,6 @@ class DailyMailIE(InfoExtractor):
'protocol': protocol, 'protocol': protocol,
'ext': 'mp4' if is_hls else None, 'ext': 'mp4' if is_hls else None,
}) })
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

@ -293,7 +293,6 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
f['url'] = f['url'].split('#')[0] f['url'] = f['url'].split('#')[0]
if not f.get('fps') and f['format_id'].endswith('@60'): if not f.get('fps') and f['format_id'].endswith('@60'):
f['fps'] = 60 f['fps'] = 60
self._sort_formats(formats)
subtitles = {} subtitles = {}
subtitles_data = try_get(metadata, lambda x: x['subtitles']['data'], dict) or {} subtitles_data = try_get(metadata, lambda x: x['subtitles']['data'], dict) or {}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save