aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/job.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/job.py')
-rw-r--r--gallery_dl/job.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/gallery_dl/job.py b/gallery_dl/job.py
index 7d08b86..b62240b 100644
--- a/gallery_dl/job.py
+++ b/gallery_dl/job.py
@@ -228,7 +228,7 @@ class DownloadJob(Job):
for pp in postprocessors:
pp.prepare(pathfmt)
- if archive and kwdict in archive:
+ if archive and archive.check(kwdict):
pathfmt.fix_extension()
self.handle_skip()
return
@@ -385,8 +385,23 @@ class DownloadJob(Job):
self.sleep = config("sleep")
if not config("download", True):
+ # monkey-patch method to do nothing and always return True
self.download = pathfmt.fix_extension
+ archive = config("archive")
+ if archive:
+ path = util.expand_path(archive)
+ try:
+ if "{" in path:
+ path = util.Formatter(path).format_map(kwdict)
+ self.archive = util.DownloadArchive(path, self.extractor)
+ except Exception as exc:
+ self.extractor.log.warning(
+ "Failed to open download archive at '%s' ('%s: %s')",
+ path, exc.__class__.__name__, exc)
+ else:
+ self.extractor.log.debug("Using download archive '%s'", path)
+
skip = config("skip", True)
if skip:
self._skipexc = None
@@ -401,21 +416,10 @@ class DownloadJob(Job):
self._skipcnt = 0
self._skipmax = text.parse_int(smax)
else:
+ # monkey-patch methods to always return False
pathfmt.exists = lambda x=None: False
-
- archive = config("archive")
- if archive:
- path = util.expand_path(archive)
- try:
- if "{" in path:
- path = util.Formatter(path).format_map(kwdict)
- self.archive = util.DownloadArchive(path, self.extractor)
- except Exception as exc:
- self.extractor.log.warning(
- "Failed to open download archive at '%s' ('%s: %s')",
- path, exc.__class__.__name__, exc)
- else:
- self.extractor.log.debug("Using download archive '%s'", path)
+ if self.archive:
+ self.archive.check = pathfmt.exists
postprocessors = self.extractor.config_accumulate("postprocessors")
if postprocessors:
@@ -449,7 +453,7 @@ class DownloadJob(Job):
def _build_blacklist(self):
wlist = self.extractor.config("whitelist")
- if wlist:
+ if wlist is not None:
if isinstance(wlist, str):
wlist = wlist.split(",")
blist = {e.category for e in extractor._list_classes()}
@@ -457,7 +461,7 @@ class DownloadJob(Job):
return blist
blist = self.extractor.config("blacklist")
- if blist:
+ if blist is not None:
if isinstance(blist, str):
blist = blist.split(",")
blist = set(blist)