From 008a08ca433cefa9266878079e70cf3da015bc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 19 Jul 2025 22:46:25 +0200 Subject: [PATCH] [ytdl] add 'deprecations' option https://github.com/gdl-org/builds/issues/3 --- docs/configuration.rst | 20 ++++++++++++++++++++ docs/gallery-dl.conf | 2 ++ gallery_dl/ytdl.py | 16 ++++++++-------- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index d021a9f0..cf5381b7 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -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 diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index c2040bd1..6abc99a9 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -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, diff --git a/gallery_dl/ytdl.py b/gallery_dl/ytdl.py index dda72c00..75899473 100644 --- a/gallery_dl/ytdl.py +++ b/gallery_dl/ytdl.py @@ -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