diff options
| author | 2021-06-22 22:30:36 -0400 | |
|---|---|---|
| committer | 2021-06-22 22:30:36 -0400 | |
| commit | 32de2b06db501c7de81678bce8e3e0c3e63d340c (patch) | |
| tree | fd58a26618a73de0faaf3e9c435a806aed7eced3 /gallery_dl/postprocessor | |
| parent | 8a644b7a06c504263a478d3681eed10b4161b5be (diff) | |
New upstream version 1.18.0.upstream/1.18.0
Diffstat (limited to 'gallery_dl/postprocessor')
| -rw-r--r-- | gallery_dl/postprocessor/classify.py | 7 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/compare.py | 7 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/exec.py | 3 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/metadata.py | 12 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/mtime.py | 4 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/ugoira.py | 4 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/zip.py | 10 |
7 files changed, 27 insertions, 20 deletions
diff --git a/gallery_dl/postprocessor/classify.py b/gallery_dl/postprocessor/classify.py index eda092d..34af1d9 100644 --- a/gallery_dl/postprocessor/classify.py +++ b/gallery_dl/postprocessor/classify.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018-2020 Mike Fährmann +# Copyright 2018-2021 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -31,9 +31,8 @@ class ClassifyPP(PostProcessor): for directory, exts in mapping.items() for ext in exts } - - job.hooks["prepare"].append(self.prepare) - job.hooks["file"].append(self.move) + job.register_hooks( + {"prepare": self.prepare, "file": self.move}, options) def prepare(self, pathfmt): ext = pathfmt.extension diff --git a/gallery_dl/postprocessor/compare.py b/gallery_dl/postprocessor/compare.py index ca416c9..1bca593 100644 --- a/gallery_dl/postprocessor/compare.py +++ b/gallery_dl/postprocessor/compare.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Mike Fährmann +# Copyright 2020-2021 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -18,11 +18,12 @@ class ComparePP(PostProcessor): PostProcessor.__init__(self, job) if options.get("shallow"): self._compare = self._compare_size - job.hooks["file"].append( + + job.register_hooks({"file": ( self.enumerate if options.get("action") == "enumerate" else self.compare - ) + )}, options) def compare(self, pathfmt): try: diff --git a/gallery_dl/postprocessor/exec.py b/gallery_dl/postprocessor/exec.py index 2514219..8fed723 100644 --- a/gallery_dl/postprocessor/exec.py +++ b/gallery_dl/postprocessor/exec.py @@ -41,8 +41,7 @@ class ExecPP(PostProcessor): events = ("after",) elif isinstance(events, str): events = events.split(",") - for event in events: - job.hooks[event].append(execute) + job.register_hooks({event: execute for event in events}, options) def exec_list(self, pathfmt, status=None): if status: diff --git a/gallery_dl/postprocessor/metadata.py b/gallery_dl/postprocessor/metadata.py index 49696a0..ef1d304 100644 --- a/gallery_dl/postprocessor/metadata.py +++ b/gallery_dl/postprocessor/metadata.py @@ -57,8 +57,7 @@ class MetadataPP(PostProcessor): events = ("file",) elif isinstance(events, str): events = events.split(",") - for event in events: - job.hooks[event].append(self.run) + job.register_hooks({event: self.run for event in events}, options) def run(self, pathfmt): directory = self._directory(pathfmt) @@ -103,11 +102,18 @@ class MetadataPP(PostProcessor): if not tags: return - if not isinstance(tags, list): + if isinstance(tags, str): taglist = tags.split(", ") if len(taglist) < len(tags) / 16: taglist = tags.split(" ") tags = taglist + elif isinstance(tags, dict): + taglists = tags.values() + tags = [] + extend = tags.extend + for taglist in taglists: + extend(taglist) + tags.sort() fp.write("\n".join(tags) + "\n") diff --git a/gallery_dl/postprocessor/mtime.py b/gallery_dl/postprocessor/mtime.py index e4c28ea..d2f1915 100644 --- a/gallery_dl/postprocessor/mtime.py +++ b/gallery_dl/postprocessor/mtime.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2019-2020 Mike Fährmann +# Copyright 2019-2021 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -17,7 +17,7 @@ class MtimePP(PostProcessor): def __init__(self, job, options): PostProcessor.__init__(self, job) self.key = options.get("key", "date") - job.hooks["file"].append(self.run) + job.register_hooks({"file": self.run}, options) def run(self, pathfmt): mtime = pathfmt.kwdict.get(self.key) diff --git a/gallery_dl/postprocessor/ugoira.py b/gallery_dl/postprocessor/ugoira.py index ac094b7..e5bdebc 100644 --- a/gallery_dl/postprocessor/ugoira.py +++ b/gallery_dl/postprocessor/ugoira.py @@ -55,8 +55,8 @@ class UgoiraPP(PostProcessor): else: self.prevent_odd = False - job.hooks["prepare"].append(self.prepare) - job.hooks["file"].append(self.convert) + job.register_hooks( + {"prepare": self.prepare, "file": self.convert}, options) def prepare(self, pathfmt): self._frames = None diff --git a/gallery_dl/postprocessor/zip.py b/gallery_dl/postprocessor/zip.py index e820280..1c4bd03 100644 --- a/gallery_dl/postprocessor/zip.py +++ b/gallery_dl/postprocessor/zip.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018-2020 Mike Fährmann +# Copyright 2018-2021 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -38,8 +38,10 @@ class ZipPP(PostProcessor): self.args = (self.path[:-1] + ext, "a", self.COMPRESSION_ALGORITHMS[algorithm], True) - job.hooks["file"].append( - self.write_safe if options.get("mode") == "safe" else self.write) + job.register_hooks({ + "file": + self.write_safe if options.get("mode") == "safe" else self.write, + }, options) job.hooks["finalize"].append(self.finalize) def write(self, pathfmt, zfile=None): @@ -56,7 +58,7 @@ class ZipPP(PostProcessor): def write_safe(self, pathfmt): with zipfile.ZipFile(*self.args) as zfile: - self._write(pathfmt, zfile) + self.write(pathfmt, zfile) def finalize(self, pathfmt, status): if self.zfile: |
