[job] add 'keywords-global' option (#6582)

https://github.com/mikf/gallery-dl/issues/6582#issuecomment-3505732704
This commit is contained in:
Mike Fährmann
2025-11-12 18:48:01 +01:00
parent d7e1351987
commit 691775d0fb
3 changed files with 25 additions and 8 deletions

View File

@@ -958,6 +958,17 @@ Description
Additional name-value pairs to be added to each metadata dictionary. 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 extractor.*.keywords-eval
------------------------- -------------------------
Type Type
@@ -969,15 +980,18 @@ Description
as a `Format String`_. as a `Format String`_.
extractor.*.keywords-default extractor.*.keywords-global
---------------------------- ---------------------------
Type Type
any ``object`` (`name``value`)
Default Example
``"None"`` ``{"type": "Original", "type_id": 1, "type_category": "meta"}``
Description Description
Default value used for missing or undefined keyword names in a Global name-value pairs to be added to each metadata dictionary.
`Format String`_. Note
Keywords defined here will be overwritten by keywords from
`extractor.keywords <extractor.*.keywords_>`__
with the same name.
extractor.*.metadata-url extractor.*.metadata-url

View File

@@ -52,8 +52,9 @@
"chapter-unique": false, "chapter-unique": false,
"keywords" : {}, "keywords" : {},
"keywords-eval" : false,
"keywords-default" : null, "keywords-default" : null,
"keywords-eval" : false,
"keywords-global" : {},
"parent-directory": false, "parent-directory": false,
"parent-metadata" : false, "parent-metadata" : false,

View File

@@ -87,6 +87,8 @@ class Job():
"current_git_head": util.git_head() "current_git_head": util.git_head()
} }
# user-supplied metadata # user-supplied metadata
if kwdict := extr.config("keywords-global"):
self.kwdict.update(kwdict)
if kwdict := extr.config("keywords"): if kwdict := extr.config("keywords"):
if extr.config("keywords-eval"): if extr.config("keywords-eval"):
self.kwdict_eval = [] self.kwdict_eval = []