@@ -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):
|
||||
|
||||
@@ -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"""
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user