diff --git a/docs/configuration.rst b/docs/configuration.rst index 7befd998..175f8690 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -344,6 +344,15 @@ Description User-Agent header value to be used for HTTP requests. =========== ===== +extractor.*.keywords +-------------------- +=========== ===== +Type ``object`` +Example ``{"type": "Pixel Art", "type_id": 123}`` +Description Additional key-value pairs to be added to each metadata dictionary. +=========== ===== + + Extractor-specific Options ========================== diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index 923d04e8..7e68ce47 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -100,7 +100,7 @@ def parse_inputfile(file): continue elif line[0] == "{": - # url-specfic config spec + # url-specific config spec try: cfd = json.loads(line) except ValueError as exc: diff --git a/gallery_dl/job.py b/gallery_dl/job.py index 36ab277f..5dd7839e 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -52,6 +52,9 @@ class Job(): self.extractor.category = parent.extractor.category self.extractor.subcategory = parent.extractor.subcategory + # user-supplied metadata + self.userkwds = self.extractor.config("keywords") + def run(self): """Execute or run the job""" try: @@ -133,9 +136,11 @@ class Job(): """Handle Message.Queue""" def update_kwdict(self, kwdict): - """Add 'category' and 'subcategory' keywords""" + """Update 'kwdict' with additional metadata""" kwdict["category"] = self.extractor.category kwdict["subcategory"] = self.extractor.subcategory + if self.userkwds: + kwdict.update(self.userkwds) def _write_unsupported(self, url): if self.ufile: