summaryrefslogtreecommitdiffstats
path: root/gallery_dl/job.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-09-09 01:57:57 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2021-09-09 01:57:57 -0400
commit3f5483df9075ae526f4c54f4cbe80edeabf6d4cc (patch)
tree6b2194fa03fd58ac35114c0dbec7561612a584b8 /gallery_dl/job.py
parentd50ba9cfe80f00e02ca9a4714f75699c00e67128 (diff)
New upstream version 1.18.4.upstream/1.18.4
Diffstat (limited to 'gallery_dl/job.py')
-rw-r--r--gallery_dl/job.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/gallery_dl/job.py b/gallery_dl/job.py
index 953d9c3..32e9bb5 100644
--- a/gallery_dl/job.py
+++ b/gallery_dl/job.py
@@ -68,12 +68,16 @@ class Job():
def run(self):
"""Execute or run the job"""
- sleep = self.extractor.config("sleep-extractor")
+ extractor = self.extractor
+ log = extractor.log
+ msg = None
+
+ sleep = extractor.config("sleep-extractor")
if sleep:
time.sleep(sleep)
+
try:
- log = self.extractor.log
- for msg in self.extractor:
+ for msg in extractor:
self.dispatch(msg)
except exception.StopExtraction as exc:
if exc.message:
@@ -100,8 +104,12 @@ class Job():
except BaseException:
self.status |= 1
raise
+ else:
+ if msg is None:
+ log.info("No results for %s", extractor.url)
finally:
self.handle_finalize()
+
return self.status
def dispatch(self, msg):
@@ -125,13 +133,6 @@ class Job():
if self.pred_queue(url, kwdict):
self.handle_queue(url, kwdict)
- elif msg[0] == Message.Version:
- if msg[1] != 1:
- raise "unsupported message-version ({}, {})".format(
- self.extractor.category, msg[1]
- )
- # TODO: support for multiple message versions
-
def handle_url(self, url, kwdict):
"""Handle Message.Url"""
@@ -199,6 +200,7 @@ class DownloadJob(Job):
Job.__init__(self, url, parent)
self.log = self.get_logger("download")
self.blacklist = None
+ self.fallback = None
self.archive = None
self.sleep = None
self.hooks = ()
@@ -237,8 +239,9 @@ class DownloadJob(Job):
# download from URL
if not self.download(url):
- # use fallback URLs if available
- for num, url in enumerate(kwdict.get("_fallback", ()), 1):
+ # use fallback URLs if available/enabled
+ fallback = kwdict.get("_fallback", ()) if self.fallback else ()
+ for num, url in enumerate(fallback, 1):
util.remove_file(pathfmt.temppath)
self.log.info("Trying fallback URL #%d", num)
if self.download(url):
@@ -394,6 +397,7 @@ class DownloadJob(Job):
pathfmt.set_directory(kwdict)
self.sleep = cfg("sleep")
+ self.fallback = cfg("fallback", True)
if not cfg("download", True):
# monkey-patch method to do nothing and always return True
self.download = pathfmt.fix_extension