diff options
| author | 2019-08-26 19:34:50 -0400 | |
|---|---|---|
| committer | 2019-08-26 19:34:50 -0400 | |
| commit | fbaff8b82a85ba1dcfa16da8af8cd98c56c9903c (patch) | |
| tree | 9c903ffe82e7df731ed424d5a578deb9ffb5cfc8 /gallery_dl/postprocessor/classify.py | |
| parent | fef60edee30ad08f646386be4c7f4c0ef0af7867 (diff) | |
| parent | b75d158d014d6c43d7d785c46c9372a9cf84d144 (diff) | |
Update upstream source from tag 'upstream/1.10.2'
Update to upstream version '1.10.2'
with Debian dir 1bbf2d0fa89411dabf6ec214a5c9df700cb070ab
Diffstat (limited to 'gallery_dl/postprocessor/classify.py')
| -rw-r--r-- | gallery_dl/postprocessor/classify.py | 23 |
1 files changed, 15 insertions, 8 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 |
