[dl:ytdl] implement dynamic download 'rate' limits (#7638)

This commit is contained in:
Mike Fährmann
2025-07-05 23:07:42 +02:00
parent 1bbacba4ed
commit 13ef48f04a
2 changed files with 19 additions and 8 deletions

View File

@@ -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: