[extractor] Deprecate _sort_formats

This commit is contained in:
pukkandan 2022-11-17 10:40:03 +05:30
parent 784320c98c
commit 9f14daf22b
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
579 changed files with 69 additions and 918 deletions

View file

@ -41,7 +41,9 @@ def do_GET(self):
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):

View file

@ -68,8 +68,7 @@ def test_prefer_free_formats(self):
{'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 @@ def test_prefer_free_formats(self):
{'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 @@ def test_prefer_free_formats(self):
{'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 @@ def test_prefer_free_formats(self):
{'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 @@ def test_format_selection_audio_exts(self):
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 @@ def format_info(f_id):
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 @@ def format_info(f_id):
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 @@ def format_info(f_id):
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 @@ def test_format_filtering(self):
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)

View file

@ -155,8 +155,6 @@ def _real_extract(self, url):
'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 @@ def tokenize_url(url, token):
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')

View file

@ -78,7 +78,6 @@ def _real_extract(self, url):
'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 @@ def _real_extract(self, url):
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,

View file

@ -27,7 +27,6 @@ def _extract_metadata(self, video_id, video_info):
**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,

View file

@ -235,7 +235,6 @@ def _real_extract(self, url):
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,

View file

@ -70,7 +70,6 @@ def _parse_video_data(self, video_data):
}) })
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 @@ def _real_extract(self, url):
'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

View file

@ -180,7 +180,6 @@ def _real_extract(self, url):
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:

View file

@ -62,7 +62,6 @@ def _extract_aen_smil(self, smil_url, video_id, auth=None):
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,

View file

@ -338,7 +338,6 @@ def _real_extract(self, url):
}] }]
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 @@ def _real_extract(self, url):
'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,

View file

@ -55,7 +55,6 @@ def _real_extract(self, url):
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 @@ def _real_extract(self, url):
'acodec': ext, 'acodec': ext,
}) })
self._sort_formats(formats)
return { return {
'id': media_id, 'id': media_id,
'formats': formats, 'formats': formats,

View file

@ -112,8 +112,6 @@ def _real_extract(self, url):
}) })
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,

View file

@ -22,7 +22,6 @@ def _extract_video(self, video_id, url=None):
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))

View file

@ -63,8 +63,6 @@ def _real_extract(self, url):
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,

View file

@ -106,7 +106,6 @@ def _real_extract(self, url):
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')]

View file

@ -84,8 +84,6 @@ def get_media_node(name, default=None):
'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 {

View file

@ -19,7 +19,6 @@ def _download_and_extract_api_data(self, video_id, netloc, cid=None):
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 {

View file

@ -354,8 +354,6 @@ def _get_anvato_videos(self, access_key, video_id, token):
}) })
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 = {

View file

@ -119,7 +119,6 @@ def _real_extract(self, url):
'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,

View file

@ -72,7 +72,6 @@ def extract(field, name=None):
'format_id': format_id, 'format_id': format_id,
'height': height, 'height': height,
}) })
self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,

View file

@ -73,7 +73,6 @@ def _real_extract(self, url):
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={})

View file

@ -120,7 +120,6 @@ def _real_extract(self, url):
'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 @@ def _clean_json(m):
'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,

View file

@ -312,7 +312,7 @@ def _real_extract(self, url):
}) })
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

View file

@ -144,7 +144,6 @@ def _real_extract(self, url):
'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 []):

View file

@ -40,8 +40,6 @@ def _parse_media_info(self, media_info, video_id, fsk):
'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 @@ def _real_extract(self, url):
'format_id': fid, 'format_id': fid,
'url': furl, 'url': furl,
}) })
self._sort_formats(formats)
info = { info = {
'formats': formats, 'formats': formats,
} }
@ -371,7 +368,6 @@ def _real_extract(self, url):
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'),

View file

@ -136,7 +136,6 @@ def _real_extract(self, url):
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,

View file

@ -73,7 +73,6 @@ def _real_extract(self, url):
'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')

View file

@ -186,7 +186,6 @@ def _real_extract(self, url):
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']

View file

@ -84,7 +84,6 @@ def _real_extract(self, url):
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 {}

View file

@ -49,7 +49,6 @@ def _extract_video_info(self, url, content, video):
'url': source_url, 'url': source_url,
'format_id': protocol, 'format_id': protocol,
}) })
self._sort_formats(formats)
return { return {
'id': clip_id, 'id': clip_id,

View file

@ -76,7 +76,6 @@ def _real_extract(self, url):
'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,

View file

@ -80,8 +80,6 @@ def _real_extract(self, url):
'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'),

View file

@ -184,8 +184,6 @@ def _real_extract(self, url):
'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 @@ def _real_extract(self, url):
'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')

View file

@ -135,7 +135,6 @@ def _real_extract(self, url):
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,

View file

@ -575,8 +575,6 @@ def _real_extract(self, url):
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 @@ def _extract_from_media_meta(self, media_meta, video_id):
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 @@ def _real_extract(self, url):
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 @@ def _real_extract(self, url):
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 @@ def _real_extract(self, url):
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 @@ def _real_extract(self, url):
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 @@ def _real_extract(self, url):
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 @@ def _real_extract(self, url):
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 @@ def _real_extract(self, url):
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 @@ def _real_extract(self, url):
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 @@ def parse_media(media):
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 @@ def extract_all(pattern):
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:

View file

@ -74,7 +74,6 @@ def _real_extract(self, url):
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():

View file

@ -76,8 +76,6 @@ def _real_extract(self, url):
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'),

View file

@ -63,8 +63,6 @@ def decode_url(quoted_b64_url):
'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 {

View file

@ -67,7 +67,6 @@ def extract_formats(self, play_info):
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 @@ def _get_formats(self, *, ep_id=None, aid=None):
'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 @@ def _real_extract(self, url):
}) })
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,

View file

@ -86,7 +86,6 @@ def _real_extract(self, url):
'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():

View file

@ -117,7 +117,6 @@ def _real_extract(self, url):
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,

View file

@ -45,7 +45,6 @@ def _real_extract(self, url):
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,

View file

@ -67,7 +67,6 @@ def _real_extract(self, url):
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,

View file

@ -21,8 +21,6 @@ def _extract_bokecc_formats(self, webpage, video_id, format_id=None):
'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

View file

@ -57,7 +57,6 @@ def _real_extract(self, url):
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,

View file

@ -67,7 +67,6 @@ def _real_extract(self, url):
'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,

View file

@ -79,8 +79,6 @@ def _real_extract(self, url):
'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 {

View file

@ -48,8 +48,6 @@ def _real_extract(self, url):
'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,

View file

@ -157,7 +157,6 @@ def _extract_formats(self, assets, media_id):
'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 @@ def _real_extract(self, url):
'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', []):

View file

@ -63,7 +63,6 @@ def _real_extract(self, url):
'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',

View file

@ -24,7 +24,6 @@ def _real_extract(self, url):
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),

View file

@ -546,8 +546,6 @@ def build_format_id(kind):
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)

View file

@ -108,7 +108,6 @@ def _real_extract(self, url):
'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,

View file

@ -49,7 +49,6 @@ def _real_extract(self, url):
'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'],

View file

@ -22,7 +22,6 @@ def _real_extract(self, url):
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,

View file

@ -54,7 +54,6 @@ def _real_extract(self, url):
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'))

View file

@ -27,7 +27,6 @@ def _real_extract(self, url):
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,

View file

@ -20,7 +20,6 @@ def _real_extract(self, url):
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,

View file

@ -84,7 +84,6 @@ def _real_extract(self, url):
else: else:
continue continue
formats.append(f) formats.append(f)
self._sort_formats(formats)
return { return {
'id': user_id, 'id': user_id,

View file

@ -47,8 +47,6 @@ def _real_extract(self, url):
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),

View file

@ -82,7 +82,6 @@ def _real_extract(self, url):
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(),

View file

@ -58,8 +58,6 @@ def _real_extract(self, url):
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,

View file

@ -86,7 +86,6 @@ def _real_extract(self, url):
'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,

View file

@ -118,7 +118,6 @@ def _real_extract(self, url):
'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):

View file

@ -43,7 +43,6 @@ def _real_extract(self, url):
'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(

View file

@ -380,8 +380,6 @@ def _real_extract(self, url):
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'],

View file

@ -52,7 +52,6 @@ def _extract_common_video_info(self, content_id, asset_types, mpx_acc, extra_inf
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,

View file

@ -132,7 +132,6 @@ def _real_extract(self, url):
}) })
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,

View file

@ -40,7 +40,6 @@ def _real_extract(self, url):
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

View file

@ -64,7 +64,6 @@ def _real_extract(self, url):
'language': language, 'language': language,
'vcodec': vcodec, 'vcodec': vcodec,
}) })
self._sort_formats(formats)
return { return {
'id': event_id, 'id': event_id,

View file

@ -81,7 +81,6 @@ def _real_extract(self, url):
'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']

View file

@ -170,8 +170,6 @@ def _real_extract(self, url):
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)

View file

@ -151,8 +151,6 @@ def _api_extract(self, video_id):
'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 @@ def extract_format(page, version):
extract_format(webpage, resolution) extract_format(webpage, resolution)
self._sort_formats(formats)
return merge_dicts(info_dict, info) return merge_dicts(info_dict, info)

View file

@ -50,7 +50,6 @@ def _real_extract(self, url):
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),

View file

@ -249,9 +249,6 @@ def _real_extract(self, url):
'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)

View file

@ -185,7 +185,6 @@ def quality(quality_id, format_url):
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', []):

View file

@ -38,8 +38,6 @@ def _real_extract(self, url):
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({

View file

@ -95,7 +95,6 @@ def _real_extract(self, url):
# 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,

View file

@ -32,7 +32,6 @@ def _get_post(self, id, post_data):
'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)

View file

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

View file

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

View file

@ -62,7 +62,6 @@ def _real_extract(self, url):
'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*'([^']+)';",

View file

@ -51,7 +51,6 @@ def _real_extract(self, url):
'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,

View file

@ -42,7 +42,6 @@ def _real_extract(self, url):
'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,

View file

@ -60,7 +60,6 @@ def _real_extract(self, url):
'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')

View file

@ -1699,7 +1699,14 @@ def __init__(ie, *args, **kwargs):
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 @@ 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))), '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 @@ def _parse_jwplayer_data(self, jwplayer_data, video_id=None, require_title=True,
'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:

View file

@ -197,7 +197,6 @@ def _extract_video(self, params):
'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():

View file

@ -69,8 +69,6 @@ def _real_extract(self, url):
'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():

View file

@ -126,7 +126,6 @@ def _real_extract(self, url):
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', []):

View file

@ -104,8 +104,6 @@ def _real_extract(self, url):
'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'))

View file

@ -54,8 +54,6 @@ def _real_extract(self, url):
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):

View file

@ -177,7 +177,6 @@ def _real_extract(self, url):
}) })
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(

View file

@ -45,7 +45,6 @@ def _real_extract(self, url):
'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,

View file

@ -60,7 +60,6 @@ def _real_extract(self, url):
'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'),

View file

@ -208,7 +208,6 @@ def _real_extract(self, url):
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,

View file

@ -218,7 +218,6 @@ def get_text_attr(d, attr):
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': (

View file

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

View file

@ -81,7 +81,6 @@ def _real_extract(self, url):
'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 @@ def _real_extract(self, url):
'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():

View file

@ -63,7 +63,6 @@ def _real_extract(self, url):
'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,

View file

@ -293,7 +293,6 @@ def _real_extract(self, url):
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