[ytdl] add 'deprecations' option

https://github.com/gdl-org/builds/issues/3
This commit is contained in:
Mike Fährmann
2025-07-19 22:46:25 +02:00
parent 240f958707
commit 008a08ca43
3 changed files with 30 additions and 8 deletions

View File

@@ -5824,6 +5824,16 @@ Description
Location of a |ytdl| configuration file to load options from.
extractor.ytdl.deprecations
---------------------------
Type
´´bool´´
Default
``false``
Description
Allow |ytdl| to warn about deprecated options and features.
extractor.ytdl.enabled
----------------------
Type
@@ -6351,6 +6361,16 @@ Description
Location of a |ytdl| configuration file to load options from.
downloader.ytdl.deprecations
----------------------------
Type
´´bool´´
Default
``false``
Description
Allow |ytdl| to warn about deprecated options and features.
downloader.ytdl.format
----------------------
Type

View File

@@ -851,6 +851,7 @@
{
"cmdline-args": null,
"config-file" : null,
"deprecations": false,
"enabled" : false,
"format" : null,
"generic" : true,
@@ -1068,6 +1069,7 @@
{
"cmdline-args" : null,
"config-file" : null,
"deprecations" : false,
"enabled" : true,
"format" : null,
"forward-cookies": true,

View File

@@ -26,14 +26,16 @@ def construct_YoutubeDL(module, obj, user_opts, system_opts=None):
opts = argv = None
config = obj.config
cfg = config("config-file")
if cfg:
if not config("deprecations"):
module.YoutubeDL.deprecated_feature = util.false
module.YoutubeDL.deprecation_warning = util.false
if cfg := config("config-file"):
with open(util.expand_path(cfg)) as fp:
contents = fp.read()
argv = shlex.split(contents, comments=True)
cmd = config("cmdline-args")
if cmd:
if cmd := config("cmdline-args"):
if isinstance(cmd, str):
cmd = shlex.split(cmd)
argv = (argv + cmd) if argv else cmd
@@ -54,8 +56,7 @@ def construct_YoutubeDL(module, obj, user_opts, system_opts=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:
if rate := config("rate"):
func = util.build_selection_func(rate, 0, text.parse_bytes)
if hasattr(func, "args"):
opts["__gdl_ratelimit_func"] = func
@@ -64,8 +65,7 @@ def construct_YoutubeDL(module, obj, user_opts, system_opts=None):
else:
opts["ratelimit"] = None
raw_opts = config("raw-options")
if raw_opts:
if raw_opts := config("raw-options"):
opts.update(raw_opts)
if config("logging", True):
opts["logger"] = obj.log