@@ -237,6 +237,9 @@ class DownloadJob(Job):
|
|||||||
self.out.success(pathfmt.path, 0)
|
self.out.success(pathfmt.path, 0)
|
||||||
if archive:
|
if archive:
|
||||||
archive.add(keywords)
|
archive.add(keywords)
|
||||||
|
if postprocessors:
|
||||||
|
for pp in postprocessors:
|
||||||
|
pp.run_after(pathfmt)
|
||||||
self._skipcnt = 0
|
self._skipcnt = 0
|
||||||
|
|
||||||
def handle_urllist(self, urls, keywords):
|
def handle_urllist(self, urls, keywords):
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ class PostProcessor():
|
|||||||
def run(self, pathfmt):
|
def run(self, pathfmt):
|
||||||
"""Execute the postprocessor for a file"""
|
"""Execute the postprocessor for a file"""
|
||||||
|
|
||||||
|
def run_after(self, pathfmt):
|
||||||
|
"""Execute postprocessor after moving a file to its target location"""
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
"""Cleanup"""
|
"""Cleanup"""
|
||||||
|
|
||||||
|
|||||||
@@ -41,25 +41,25 @@ class ExecPP(PostProcessor):
|
|||||||
if options.get("async", False):
|
if options.get("async", False):
|
||||||
self._exec = self._exec_async
|
self._exec = self._exec_async
|
||||||
|
|
||||||
def run(self, pathfmt):
|
def run_after(self, pathfmt):
|
||||||
self._exec(self._format(pathfmt))
|
self._exec(self._format(pathfmt))
|
||||||
|
|
||||||
def _format_args_string(self, 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):
|
def _format_args_list(self, pathfmt):
|
||||||
kwdict = pathfmt.kwdict
|
kwdict = pathfmt.kwdict
|
||||||
kwdict["_directory"] = pathfmt.realdirectory
|
kwdict["_directory"] = pathfmt.realdirectory
|
||||||
kwdict["_filename"] = pathfmt.filename
|
kwdict["_filename"] = pathfmt.filename
|
||||||
kwdict["_temppath"] = pathfmt.temppath
|
|
||||||
kwdict["_path"] = pathfmt.realpath
|
kwdict["_path"] = pathfmt.realpath
|
||||||
return [arg.format_map(kwdict) for arg in self.args]
|
return [arg.format_map(kwdict) for arg in self.args]
|
||||||
|
|
||||||
def _exec(self, args):
|
def _exec(self, args):
|
||||||
|
self.log.debug("Running '%s'", args)
|
||||||
retcode = subprocess.Popen(args, shell=self.shell).wait()
|
retcode = subprocess.Popen(args, shell=self.shell).wait()
|
||||||
if retcode:
|
if retcode:
|
||||||
self.log.warning(
|
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)
|
" ".join(args) if isinstance(args, list) else args, retcode)
|
||||||
|
|
||||||
def _exec_async(self, args):
|
def _exec_async(self, args):
|
||||||
|
|||||||
Reference in New Issue
Block a user