mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 01:02:48 +01:00
Filter and sort videos before calling list_formats
This commit is contained in:
parent
e56f22ae20
commit
bfaae0a768
@ -662,10 +662,6 @@ def process_video_result(self, info_dict, download=True):
|
|||||||
if 'ext' not in format:
|
if 'ext' not in format:
|
||||||
format['ext'] = determine_ext(format['url'])
|
format['ext'] = determine_ext(format['url'])
|
||||||
|
|
||||||
if self.params.get('listformats', None):
|
|
||||||
self.list_formats(info_dict)
|
|
||||||
return
|
|
||||||
|
|
||||||
format_limit = self.params.get('format_limit', None)
|
format_limit = self.params.get('format_limit', None)
|
||||||
if format_limit:
|
if format_limit:
|
||||||
formats = list(takewhile_inclusive(
|
formats = list(takewhile_inclusive(
|
||||||
@ -681,6 +677,11 @@ def _free_formats_key(f):
|
|||||||
return (f.get('height'), f.get('width'), ext_ord)
|
return (f.get('height'), f.get('width'), ext_ord)
|
||||||
formats = sorted(formats, key=_free_formats_key)
|
formats = sorted(formats, key=_free_formats_key)
|
||||||
|
|
||||||
|
info_dict['formats'] = formats
|
||||||
|
if self.params.get('listformats', None):
|
||||||
|
self.list_formats(info_dict)
|
||||||
|
return
|
||||||
|
|
||||||
req_format = self.params.get('format', 'best')
|
req_format = self.params.get('format', 'best')
|
||||||
if req_format is None:
|
if req_format is None:
|
||||||
req_format = 'best'
|
req_format = 'best'
|
||||||
|
Loading…
Reference in New Issue
Block a user