From 691775d0fb9cb3a29dad6feeafa254072a7ea152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 12 Nov 2025 18:48:01 +0100 Subject: [PATCH] [job] add 'keywords-global' option (#6582) https://github.com/mikf/gallery-dl/issues/6582#issuecomment-3505732704 --- docs/configuration.rst | 28 +++++++++++++++++++++------- docs/gallery-dl.conf | 3 ++- gallery_dl/job.py | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 9f2c5220..eeff5d63 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -958,6 +958,17 @@ Description Additional name-value pairs to be added to each metadata dictionary. +extractor.*.keywords-default +---------------------------- +Type + any +Default + ``"None"`` +Description + Default value used for missing or undefined keyword names in a + `Format String`_. + + extractor.*.keywords-eval ------------------------- Type @@ -969,15 +980,18 @@ Description as a `Format String`_. -extractor.*.keywords-default ----------------------------- +extractor.*.keywords-global +--------------------------- Type - any -Default - ``"None"`` + ``object`` (`name` → `value`) +Example + ``{"type": "Original", "type_id": 1, "type_category": "meta"}`` Description - Default value used for missing or undefined keyword names in a - `Format String`_. + Global name-value pairs to be added to each metadata dictionary. +Note + Keywords defined here will be overwritten by keywords from + `extractor.keywords `__ + with the same name. extractor.*.metadata-url diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index b120ddac..7e02122a 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -52,8 +52,9 @@ "chapter-unique": false, "keywords" : {}, - "keywords-eval" : false, "keywords-default" : null, + "keywords-eval" : false, + "keywords-global" : {}, "parent-directory": false, "parent-metadata" : false, diff --git a/gallery_dl/job.py b/gallery_dl/job.py index d1664732..5ba87f4a 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -87,6 +87,8 @@ class Job(): "current_git_head": util.git_head() } # user-supplied metadata + if kwdict := extr.config("keywords-global"): + self.kwdict.update(kwdict) if kwdict := extr.config("keywords"): if extr.config("keywords-eval"): self.kwdict_eval = []