[dl:ytdl] implement dynamic download 'rate' limits (#7638)
This commit is contained in:
@@ -49,18 +49,20 @@ def construct_YoutubeDL(module, obj, user_opts, system_opts=None):
|
||||
opts["nopart"] = not config("part", True)
|
||||
if opts.get("updatetime") is None:
|
||||
opts["updatetime"] = config("mtime", True)
|
||||
if opts.get("ratelimit") is None:
|
||||
rate = config("rate")
|
||||
if rate:
|
||||
func = util.build_selection_func(rate, 0, text.parse_bytes)
|
||||
rmax = func.args[1] if hasattr(func, "args") else func()
|
||||
opts["ratelimit"] = rmax or None
|
||||
else:
|
||||
opts["ratelimit"] = None
|
||||
if opts.get("min_filesize") is None:
|
||||
opts["min_filesize"] = text.parse_bytes(config("filesize-min"), None)
|
||||
if opts.get("max_filesize") is None:
|
||||
opts["max_filesize"] = text.parse_bytes(config("filesize-max"), None)
|
||||
if opts.get("ratelimit") is None:
|
||||
rate = config("rate")
|
||||
if rate:
|
||||
func = util.build_selection_func(rate, 0, text.parse_bytes)
|
||||
if hasattr(func, "args"):
|
||||
opts["_gdl_ratelimit"] = func
|
||||
else:
|
||||
opts["ratelimit"] = func() or None
|
||||
else:
|
||||
opts["ratelimit"] = None
|
||||
|
||||
raw_opts = config("raw-options")
|
||||
if raw_opts:
|
||||
|
||||
Reference in New Issue
Block a user