diff options
| author | 2023-10-22 01:00:20 -0400 | |
|---|---|---|
| committer | 2023-10-22 01:00:20 -0400 | |
| commit | eec4f7f008e8ea79fb188d1a83899ffc111c01f6 (patch) | |
| tree | 296978db828683b62f28966b33c71ab65de6ef32 /gallery_dl/postprocessor/exec.py | |
| parent | 2a69d9df4852d040011999e269be4390b253ed92 (diff) | |
| parent | e052f3b9e1d9703a5a466daeaf37bacf476c2daf (diff) | |
Update upstream source from tag 'upstream/1.26.1'
Update to upstream version '1.26.1'
with Debian dir 0ae933d6689388e4d54c2e1b49ae788c18b91545
Diffstat (limited to 'gallery_dl/postprocessor/exec.py')
| -rw-r--r-- | gallery_dl/postprocessor/exec.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gallery_dl/postprocessor/exec.py b/gallery_dl/postprocessor/exec.py index afa828c..e7ed2f6 100644 --- a/gallery_dl/postprocessor/exec.py +++ b/gallery_dl/postprocessor/exec.py @@ -12,6 +12,7 @@ from .common import PostProcessor from .. import util, formatter import subprocess import os +import re if util.WINDOWS: @@ -32,6 +33,7 @@ class ExecPP(PostProcessor): args = options["command"] if isinstance(args, str): self.args = args + self._sub = re.compile(r"\{(_directory|_filename|_path|)\}").sub execute = self.exec_string else: self.args = [formatter.parse(arg) for arg in args] @@ -69,11 +71,8 @@ class ExecPP(PostProcessor): if archive and archive.check(pathfmt.kwdict): return - if pathfmt.realpath: - args = self.args.replace("{}", quote(pathfmt.realpath)) - else: - args = self.args.replace("{}", quote(pathfmt.realdirectory)) - + self.pathfmt = pathfmt + args = self._sub(self._replace, self.args) self._exec(args, True) if archive: @@ -90,5 +89,13 @@ class ExecPP(PostProcessor): self.log.debug("Running '%s'", args) subprocess.Popen(args, shell=shell) + def _replace(self, match): + name = match.group(1) + if name == "_directory": + return quote(self.pathfmt.realdirectory) + if name == "_filename": + return quote(self.pathfmt.filename) + return quote(self.pathfmt.realpath) + __postprocessor__ = ExecPP |
