diff options
| author | 2020-12-13 23:07:42 -0500 | |
|---|---|---|
| committer | 2020-12-13 23:07:42 -0500 | |
| commit | 8f7c87a2697113134c311aaeafd9c919555a2741 (patch) | |
| tree | 4ff7316ac1570683b3c968fd30d044925e47a2a5 /gallery_dl/postprocessor/compare.py | |
| parent | 143723944033d7a6593d57bd1cf6ae97713b6ce7 (diff) | |
New upstream version 1.16.0.upstream/1.16.0
Diffstat (limited to 'gallery_dl/postprocessor/compare.py')
| -rw-r--r-- | gallery_dl/postprocessor/compare.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/gallery_dl/postprocessor/compare.py b/gallery_dl/postprocessor/compare.py index 0d11844..ca416c9 100644 --- a/gallery_dl/postprocessor/compare.py +++ b/gallery_dl/postprocessor/compare.py @@ -16,22 +16,25 @@ class ComparePP(PostProcessor): def __init__(self, job, options): PostProcessor.__init__(self, job) - if options.get("action") == "enumerate": - self.run = self._run_enumerate if options.get("shallow"): - self.compare = self._compare_size + self._compare = self._compare_size + job.hooks["file"].append( + self.enumerate + if options.get("action") == "enumerate" else + self.compare + ) - def run(self, pathfmt): + def compare(self, pathfmt): try: - if self.compare(pathfmt.realpath, pathfmt.temppath): + if self._compare(pathfmt.realpath, pathfmt.temppath): pathfmt.delete = True except OSError: pass - def _run_enumerate(self, pathfmt): + def enumerate(self, pathfmt): num = 1 try: - while not self.compare(pathfmt.realpath, pathfmt.temppath): + while not self._compare(pathfmt.realpath, pathfmt.temppath): pathfmt.prefix = str(num) + "." pathfmt.set_extension(pathfmt.extension, False) num += 1 @@ -39,7 +42,7 @@ class ComparePP(PostProcessor): except OSError: pass - def compare(self, f1, f2): + def _compare(self, f1, f2): return self._compare_size(f1, f2) and self._compare_content(f1, f2) @staticmethod |
