diff --git a/gallery_dl/job.py b/gallery_dl/job.py index d5297050..8b610248 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -237,6 +237,9 @@ class DownloadJob(Job): self.out.success(pathfmt.path, 0) if archive: archive.add(keywords) + if postprocessors: + for pp in postprocessors: + pp.run_after(pathfmt) self._skipcnt = 0 def handle_urllist(self, urls, keywords): diff --git a/gallery_dl/postprocessor/common.py b/gallery_dl/postprocessor/common.py index b967cf6a..dcaf273e 100644 --- a/gallery_dl/postprocessor/common.py +++ b/gallery_dl/postprocessor/common.py @@ -21,6 +21,9 @@ class PostProcessor(): def run(self, pathfmt): """Execute the postprocessor for a file""" + def run_after(self, pathfmt): + """Execute postprocessor after moving a file to its target location""" + def finalize(self): """Cleanup""" diff --git a/gallery_dl/postprocessor/exec.py b/gallery_dl/postprocessor/exec.py index 206dd56e..19a9b87d 100644 --- a/gallery_dl/postprocessor/exec.py +++ b/gallery_dl/postprocessor/exec.py @@ -41,25 +41,25 @@ class ExecPP(PostProcessor): if options.get("async", False): self._exec = self._exec_async - def run(self, pathfmt): + def run_after(self, pathfmt): self._exec(self._format(pathfmt)) def _format_args_string(self, pathfmt): - return self.args.replace("{}", quote(pathfmt.temppath)) + return self.args.replace("{}", quote(pathfmt.realpath)) def _format_args_list(self, pathfmt): kwdict = pathfmt.kwdict kwdict["_directory"] = pathfmt.realdirectory kwdict["_filename"] = pathfmt.filename - kwdict["_temppath"] = pathfmt.temppath kwdict["_path"] = pathfmt.realpath return [arg.format_map(kwdict) for arg in self.args] def _exec(self, args): + self.log.debug("Running '%s'", args) retcode = subprocess.Popen(args, shell=self.shell).wait() if retcode: self.log.warning( - "executing '%s' returned with non-zero exit status (%d)", + "Executing '%s' returned with non-zero exit status (%d)", " ".join(args) if isinstance(args, list) else args, retcode) def _exec_async(self, args):