diff --git a/gallery_dl/postprocessor/zip.py b/gallery_dl/postprocessor/zip.py index fc5636f3..01e31a08 100644 --- a/gallery_dl/postprocessor/zip.py +++ b/gallery_dl/postprocessor/zip.py @@ -10,6 +10,7 @@ from .common import PostProcessor import zipfile +import os class ZipPP(PostProcessor): @@ -32,9 +33,10 @@ class ZipPP(PostProcessor): algorithm) algorithm = "store" - path = pathfmt.realdirectory + self.ext + self.path = pathfmt.realdirectory self.zfile = zipfile.ZipFile( - path, "a", self.COMPRESSION_ALGORITHMS[algorithm], True) + self.path + self.ext, "a", + self.COMPRESSION_ALGORITHMS[algorithm], True) def run(self, pathfmt): # 'NameToInfo' is not officially documented, but it's available @@ -47,5 +49,11 @@ class ZipPP(PostProcessor): def finalize(self): self.zfile.close() + if self.delete: + try: + os.rmdir(self.path) + except OSError: + pass + __postprocessor__ = ZipPP