diff options
| author | 2019-08-26 19:34:45 -0400 | |
|---|---|---|
| committer | 2019-08-26 19:34:45 -0400 | |
| commit | b75d158d014d6c43d7d785c46c9372a9cf84d144 (patch) | |
| tree | 7dca4a7e61fe8b6e2bff2142fc19891e783a7d6d /gallery_dl/postprocessor | |
| parent | 64ad8e7bd15df71ab1116eede414558631bcad32 (diff) | |
New upstream version 1.10.2upstream/1.10.2
Diffstat (limited to 'gallery_dl/postprocessor')
| -rw-r--r-- | gallery_dl/postprocessor/classify.py | 23 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/common.py | 5 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/metadata.py | 15 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/mtime.py | 4 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/ugoira.py | 10 |
5 files changed, 33 insertions, 24 deletions
diff --git a/gallery_dl/postprocessor/classify.py b/gallery_dl/postprocessor/classify.py index 62460d3..4a9bde9 100644 --- a/gallery_dl/postprocessor/classify.py +++ b/gallery_dl/postprocessor/classify.py @@ -33,17 +33,24 @@ class ClassifyPP(PostProcessor): } def prepare(self, pathfmt): - ext = pathfmt.keywords.get("extension") - + ext = pathfmt.extension if ext in self.mapping: - self._dir = pathfmt.realdirectory + os.sep + self.mapping[ext] - pathfmt.realpath = self._dir + os.sep + pathfmt.filename - else: - self._dir = None + # set initial paths to enable download skips + self._build_paths(pathfmt, self.mapping[ext]) def run(self, pathfmt): - if self._dir: - os.makedirs(self._dir, exist_ok=True) + ext = pathfmt.extension + if ext in self.mapping: + # rebuild paths in case the filename extension changed + path = self._build_paths(pathfmt, self.mapping[ext]) + os.makedirs(path, exist_ok=True) + + @staticmethod + def _build_paths(pathfmt, extra): + path = pathfmt.realdirectory + extra + pathfmt.realpath = path + os.sep + pathfmt.filename + pathfmt.path = pathfmt.directory + extra + os.sep + pathfmt.filename + return path __postprocessor__ = ClassifyPP diff --git a/gallery_dl/postprocessor/common.py b/gallery_dl/postprocessor/common.py index c642f0f..b967cf6 100644 --- a/gallery_dl/postprocessor/common.py +++ b/gallery_dl/postprocessor/common.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018 Mike Fährmann +# Copyright 2018-2019 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 @@ -23,3 +23,6 @@ class PostProcessor(): def finalize(self): """Cleanup""" + + def __repr__(self): + return self.__class__.__name__ diff --git a/gallery_dl/postprocessor/metadata.py b/gallery_dl/postprocessor/metadata.py index 77be9c7..467ef11 100644 --- a/gallery_dl/postprocessor/metadata.py +++ b/gallery_dl/postprocessor/metadata.py @@ -36,15 +36,14 @@ class MetadataPP(PostProcessor): def run(self, pathfmt): path = "{}.{}".format(pathfmt.realpath, self.extension) with open(path, "w", encoding="utf-8") as file: - self.write(file, pathfmt) + self.write(file, pathfmt.kwdict) - def _write_custom(self, file, pathfmt): - output = self.formatter.format_map(pathfmt.keywords) + def _write_custom(self, file, kwdict): + output = self.formatter.format_map(kwdict) file.write(output) - def _write_tags(self, file, pathfmt): - kwds = pathfmt.keywords - tags = kwds.get("tags") or kwds.get("tag_string") + def _write_tags(self, file, kwdict): + tags = kwdict.get("tags") or kwdict.get("tag_string") if not tags: return @@ -58,8 +57,8 @@ class MetadataPP(PostProcessor): file.write("\n".join(tags)) file.write("\n") - def _write_json(self, file, pathfmt): - util.dump_json(pathfmt.keywords, file, self.ascii, self.indent) + def _write_json(self, file, kwdict): + util.dump_json(kwdict, file, self.ascii, self.indent) __postprocessor__ = MetadataPP diff --git a/gallery_dl/postprocessor/mtime.py b/gallery_dl/postprocessor/mtime.py index 03d2f11..7065428 100644 --- a/gallery_dl/postprocessor/mtime.py +++ b/gallery_dl/postprocessor/mtime.py @@ -19,9 +19,9 @@ class MtimePP(PostProcessor): self.key = options.get("key", "date") def run(self, pathfmt): - mtime = pathfmt.keywords.get(self.key) + mtime = pathfmt.kwdict.get(self.key) ts = getattr(mtime, "timestamp", None) - pathfmt.keywords["_mtime"] = ts() if ts else parse_int(mtime) + pathfmt.kwdict["_mtime"] = ts() if ts else parse_int(mtime) __postprocessor__ = MtimePP diff --git a/gallery_dl/postprocessor/ugoira.py b/gallery_dl/postprocessor/ugoira.py index bd8c5ad..0dbb796 100644 --- a/gallery_dl/postprocessor/ugoira.py +++ b/gallery_dl/postprocessor/ugoira.py @@ -52,13 +52,13 @@ class UgoiraPP(PostProcessor): def prepare(self, pathfmt): self._frames = None - if pathfmt.keywords["extension"] != "zip": + if pathfmt.extension != "zip": return - if "frames" in pathfmt.keywords: - self._frames = pathfmt.keywords["frames"] - elif "pixiv_ugoira_frame_data" in pathfmt.keywords: - self._frames = pathfmt.keywords["pixiv_ugoira_frame_data"]["data"] + if "frames" in pathfmt.kwdict: + self._frames = pathfmt.kwdict["frames"] + elif "pixiv_ugoira_frame_data" in pathfmt.kwdict: + self._frames = pathfmt.kwdict["pixiv_ugoira_frame_data"]["data"] else: return |
