aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/postprocessor/execafterdownload.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-04-11 05:39:55 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-04-11 06:06:12 +0530
commit9de3ea31269c396dabf5b26f92fa65bc99038ede (patch)
tree4be7d0a920a52f8f9b43696857c3c21eff99cdf9 /yt_dlp/postprocessor/execafterdownload.py
parente01d6aa4352ea76059f4dfcd06637311dc8a8389 (diff)
downloadhypervideo-pre-9de3ea31269c396dabf5b26f92fa65bc99038ede.tar.lz
hypervideo-pre-9de3ea31269c396dabf5b26f92fa65bc99038ede.tar.xz
hypervideo-pre-9de3ea31269c396dabf5b26f92fa65bc99038ede.zip
Pass any field to `--exec` using similar syntax to output template
Related: https://github.com/ytdl-org/youtube-dl/issues/28642
Diffstat (limited to 'yt_dlp/postprocessor/execafterdownload.py')
-rw-r--r--yt_dlp/postprocessor/execafterdownload.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/yt_dlp/postprocessor/execafterdownload.py b/yt_dlp/postprocessor/execafterdownload.py
index 24dc64ef0..95159cbc2 100644
--- a/yt_dlp/postprocessor/execafterdownload.py
+++ b/yt_dlp/postprocessor/execafterdownload.py
@@ -20,12 +20,13 @@ class ExecAfterDownloadPP(PostProcessor):
def pp_key(cls):
return 'Exec'
- def run(self, information):
- cmd = self.exec_cmd
- if '{}' not in cmd:
- cmd += ' {}'
-
- cmd = cmd.replace('{}', compat_shlex_quote(information['filepath']))
+ def run(self, info):
+ tmpl, info_copy = self._downloader.prepare_outtmpl(self.exec_cmd, info)
+ cmd = tmpl % info_copy
+ if cmd == self.exec_cmd: # No replacements were made
+ if '{}' not in self.exec_cmd:
+ self.exec_cmd += ' {}'
+ cmd = self.exec_cmd.replace('{}', compat_shlex_quote(info['filepath']))
self.to_screen('Executing command: %s' % cmd)
retCode = subprocess.call(encodeArgument(cmd), shell=True)
@@ -33,4 +34,4 @@ class ExecAfterDownloadPP(PostProcessor):
raise PostProcessingError(
'Command returned error code %d' % retCode)
- return [], information
+ return [], info