mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-10-02 06:18:37 +09:00
Extend #980 with --max-quality support
This commit is contained in:
@@ -488,7 +488,9 @@ class YoutubeDL(object):
|
||||
|
||||
format_limit = self.params.get('format_limit', None)
|
||||
if format_limit:
|
||||
formats = [f for f in formats if f['format_id'] <= format_limit]
|
||||
formats = list(takewhile_inclusive(
|
||||
lambda f: f['format_id'] != format_limit, formats
|
||||
))
|
||||
if self.params.get('prefer_free_formats'):
|
||||
def _free_formats_key(f):
|
||||
try:
|
||||
|
@@ -947,6 +947,15 @@ def shell_quote(args):
|
||||
return ' '.join(map(pipes.quote, args))
|
||||
|
||||
|
||||
def takewhile_inclusive(pred, seq):
|
||||
""" Like itertools.takewhile, but include the latest evaluated element
|
||||
(the first element so that Not pred(e)) """
|
||||
for e in seq:
|
||||
yield e
|
||||
if not pred(e):
|
||||
return
|
||||
|
||||
|
||||
def smuggle_url(url, data):
|
||||
""" Pass additional data in a URL for internal use. """
|
||||
|
||||
|
Reference in New Issue
Block a user