aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/postprocessor
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2019-11-10 22:14:10 -0500
committerLibravatarUnit 193 <unit193@ubuntu.com>2019-11-10 22:14:10 -0500
commit0c73e982fa596da07f23b377621ab894a9e64884 (patch)
tree96f6a40a5656c15a2ec7217a8a1efcff5827bcbb /gallery_dl/postprocessor
parent40f5fe6edef268632d3bc484e85e5b37bad67bff (diff)
New upstream version 1.11.1upstream/1.11.1
Diffstat (limited to 'gallery_dl/postprocessor')
-rw-r--r--gallery_dl/postprocessor/common.py4
-rw-r--r--gallery_dl/postprocessor/exec.py22
-rw-r--r--gallery_dl/postprocessor/zip.py2
3 files changed, 22 insertions, 6 deletions
diff --git a/gallery_dl/postprocessor/common.py b/gallery_dl/postprocessor/common.py
index 71ef932..83b42eb 100644
--- a/gallery_dl/postprocessor/common.py
+++ b/gallery_dl/postprocessor/common.py
@@ -31,8 +31,8 @@ class PostProcessor():
"""Execute postprocessor after moving a file to its target location"""
@staticmethod
- def finalize():
- """Cleanup"""
+ def run_final(pathfmt, status):
+ """Postprocessor finalization after all files have been downloaded"""
def __repr__(self):
return self.__class__.__name__
diff --git a/gallery_dl/postprocessor/exec.py b/gallery_dl/postprocessor/exec.py
index 19a9b87..0a56281 100644
--- a/gallery_dl/postprocessor/exec.py
+++ b/gallery_dl/postprocessor/exec.py
@@ -26,17 +26,26 @@ class ExecPP(PostProcessor):
def __init__(self, pathfmt, options):
PostProcessor.__init__(self)
args = options["command"]
+ final = options.get("final", False)
if isinstance(args, str):
+ if final:
+ self._format = self._format_args_directory
+ else:
+ self._format = self._format_args_path
if "{}" not in args:
args += " {}"
self.args = args
self.shell = True
- self._format = self._format_args_string
else:
+ self._format = self._format_args_list
self.args = [util.Formatter(arg) for arg in args]
self.shell = False
- self._format = self._format_args_list
+
+ if final:
+ self.run_after = PostProcessor.run_after
+ else:
+ self.run_final = PostProcessor.run_final
if options.get("async", False):
self._exec = self._exec_async
@@ -44,9 +53,16 @@ class ExecPP(PostProcessor):
def run_after(self, pathfmt):
self._exec(self._format(pathfmt))
- def _format_args_string(self, pathfmt):
+ def run_final(self, pathfmt, status):
+ if status == 0:
+ self._exec(self._format(pathfmt))
+
+ def _format_args_path(self, pathfmt):
return self.args.replace("{}", quote(pathfmt.realpath))
+ def _format_args_directory(self, pathfmt):
+ return self.args.replace("{}", quote(pathfmt.realdirectory))
+
def _format_args_list(self, pathfmt):
kwdict = pathfmt.kwdict
kwdict["_directory"] = pathfmt.realdirectory
diff --git a/gallery_dl/postprocessor/zip.py b/gallery_dl/postprocessor/zip.py
index 6659a8d..42f7608 100644
--- a/gallery_dl/postprocessor/zip.py
+++ b/gallery_dl/postprocessor/zip.py
@@ -59,7 +59,7 @@ class ZipPP(PostProcessor):
with zipfile.ZipFile(*self.args) as zfile:
self._write(pathfmt, zfile)
- def finalize(self):
+ def run_final(self, pathfmt, status):
if self.zfile:
self.zfile.close()