summaryrefslogtreecommitdiffstats
path: root/gallery_dl/job.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-04-13 19:33:47 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2021-04-13 19:33:47 -0400
commitd27dcd4646242d6da8436f14c7b37ce864355858 (patch)
treec5c86ca7435010b6b13933217a1921430cf95dc4 /gallery_dl/job.py
parent3201d77a148367d739862b4f07868a76eaeb7cb1 (diff)
New upstream version 1.17.2.upstream/1.17.2
Diffstat (limited to 'gallery_dl/job.py')
-rw-r--r--gallery_dl/job.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/gallery_dl/job.py b/gallery_dl/job.py
index 0f40bb9..d3b4a90 100644
--- a/gallery_dl/job.py
+++ b/gallery_dl/job.py
@@ -42,7 +42,14 @@ class Job():
self.status = 0
self.pred_url = self._prepare_predicates("image", True)
self.pred_queue = self._prepare_predicates("chapter", False)
+ self.kwdict = {}
+ # user-supplied metadata
+ kwdict = self.extractor.config("keywords")
+ if kwdict:
+ self.kwdict.update(kwdict)
+
+ # data from parent job
if parent:
pextr = parent.extractor
@@ -57,9 +64,6 @@ class Job():
# reuse connection adapters
extr.session.adapters = pextr.session.adapters
- # user-supplied metadata
- self.userkwds = self.extractor.config("keywords")
-
def run(self):
"""Execute or run the job"""
sleep = self.extractor.config("sleep-extractor")
@@ -137,8 +141,8 @@ class Job():
extr = self.extractor
kwdict["category"] = extr.category
kwdict["subcategory"] = extr.subcategory
- if self.userkwds:
- kwdict.update(self.userkwds)
+ if self.kwdict:
+ kwdict.update(self.kwdict)
def _prepare_predicates(self, target, skip=True):
predicates = []
@@ -183,7 +187,7 @@ class Job():
class DownloadJob(Job):
"""Download images into appropriate directory/filename locations"""
- def __init__(self, url, parent=None):
+ def __init__(self, url, parent=None, kwdict=None):
Job.__init__(self, url, parent)
self.log = self.get_logger("download")
self.blacklist = None
@@ -198,6 +202,11 @@ class DownloadJob(Job):
pfmt = parent.pathfmt
if pfmt and parent.extractor.config("parent-directory"):
self.extractor._parentdir = pfmt.directory
+ if parent.extractor.config("parent-metadata"):
+ if parent.kwdict:
+ self.kwdict.update(parent.kwdict)
+ if kwdict:
+ self.kwdict.update(kwdict)
else:
self.visited = set()
@@ -280,8 +289,9 @@ class DownloadJob(Job):
return
self.visited.add(url)
- if "_extractor" in kwdict:
- extr = kwdict["_extractor"].from_url(url)
+ cls = kwdict.get("_extractor")
+ if cls:
+ extr = cls.from_url(url)
else:
extr = extractor.find(url)
if extr:
@@ -291,7 +301,7 @@ class DownloadJob(Job):
extr = None
if extr:
- self.status |= self.__class__(extr, self).run()
+ self.status |= self.__class__(extr, self, kwdict).run()
else:
self._write_unsupported(url)
@@ -474,7 +484,9 @@ class DownloadJob(Job):
class SimulationJob(DownloadJob):
"""Simulate the extraction process without downloading anything"""
- def handle_url(self, url, kwdict, fallback=None):
+ def handle_url(self, url, kwdict):
+ if not kwdict["extension"]:
+ kwdict["extension"] = "jpg"
self.pathfmt.set_filename(kwdict)
self.out.skip(self.pathfmt.path)
if self.sleep: