diff options
| author | 2021-10-05 23:30:14 -0400 | |
|---|---|---|
| committer | 2021-10-05 23:30:14 -0400 | |
| commit | 8b421b927aefe1cc21d54db8c6abfba6bd754096 (patch) | |
| tree | 12c3db412bf13c53ef576f6053681575f66fb36a /gallery_dl/postprocessor/compare.py | |
| parent | 17e8877df22d5a965d3c92ce640b089e88d82d2b (diff) | |
| parent | 34ba2951b8c523713425c98addb9256ea05c946f (diff) | |
Update upstream source from tag 'upstream/1.19.0'
Update to upstream version '1.19.0'
with Debian dir bc64f5039c209cd32cdb1030e3058fdb88976bac
Diffstat (limited to 'gallery_dl/postprocessor/compare.py')
| -rw-r--r-- | gallery_dl/postprocessor/compare.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/gallery_dl/postprocessor/compare.py b/gallery_dl/postprocessor/compare.py index 1bca593..a08cdc4 100644 --- a/gallery_dl/postprocessor/compare.py +++ b/gallery_dl/postprocessor/compare.py @@ -9,6 +9,8 @@ """Compare versions of the same file and replace/enumerate them on mismatch""" from .common import PostProcessor +from .. import text, util, exception +import sys import os @@ -19,16 +21,33 @@ class ComparePP(PostProcessor): if options.get("shallow"): self._compare = self._compare_size - job.register_hooks({"file": ( - self.enumerate - if options.get("action") == "enumerate" else - self.compare - )}, options) + action = options.get("action") + if action == "enumerate": + job.register_hooks({"file": self.enumerate}, options) + else: + job.register_hooks({"file": self.compare}, options) + action, _, smax = action.partition(":") + self._skipmax = text.parse_int(smax) + self._skipexc = self._skipcnt = 0 + if action == "abort": + self._skipexc = exception.StopExtraction + elif action == "terminate": + self._skipexc = exception.TerminateExtraction + elif action == "exit": + self._skipexc = sys.exit def compare(self, pathfmt): try: if self._compare(pathfmt.realpath, pathfmt.temppath): + if self._skipexc: + self._skipcnt += 1 + if self._skipcnt >= self._skipmax: + util.remove_file(pathfmt.temppath) + print() + raise self._skipexc() pathfmt.delete = True + else: + self._skipcnt = 0 except OSError: pass |
