1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 04:02:32 +01:00

add option to specify additional key-value pairs

This commit is contained in:
Mike Fährmann 2018-02-08 23:10:58 +01:00
parent d38bf2f54c
commit 7f7c16ae37
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 16 additions and 2 deletions

View File

@ -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
==========================

View File

@ -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:

View File

@ -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: