aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/postprocessor/execafterdownload.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-08-07 13:30:55 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-08-07 21:17:07 +0530
commitc681cb5d931b61a4370c56c8da82f01f3983f000 (patch)
tree75397ab36a43a11c38cd886793d3b57948d22ccb /yt_dlp/postprocessor/execafterdownload.py
parent379e44ed3cf3b030cc592e2b557a2dfa836242f9 (diff)
downloadhypervideo-pre-c681cb5d931b61a4370c56c8da82f01f3983f000.tar.lz
hypervideo-pre-c681cb5d931b61a4370c56c8da82f01f3983f000.tar.xz
hypervideo-pre-c681cb5d931b61a4370c56c8da82f01f3983f000.zip
Allow multiple `--exec` and `--exec-before-download`
Diffstat (limited to 'yt_dlp/postprocessor/execafterdownload.py')
-rw-r--r--yt_dlp/postprocessor/execafterdownload.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/yt_dlp/postprocessor/execafterdownload.py b/yt_dlp/postprocessor/execafterdownload.py
index ce77c6e80..182b900d9 100644
--- a/yt_dlp/postprocessor/execafterdownload.py
+++ b/yt_dlp/postprocessor/execafterdownload.py
@@ -7,6 +7,7 @@ from ..compat import compat_shlex_quote
from ..utils import (
encodeArgument,
PostProcessingError,
+ variadic,
)
@@ -14,7 +15,7 @@ class ExecAfterDownloadPP(PostProcessor):
def __init__(self, downloader, exec_cmd):
super(ExecAfterDownloadPP, self).__init__(downloader)
- self.exec_cmd = exec_cmd
+ self.exec_cmd = variadic(exec_cmd)
@classmethod
def pp_key(cls):
@@ -32,9 +33,10 @@ class ExecAfterDownloadPP(PostProcessor):
info.get('filepath') or info['_filename']))
def run(self, info):
- cmd = self.parse_cmd(self.exec_cmd, info)
- self.to_screen('Executing command: %s' % cmd)
- retCode = subprocess.call(encodeArgument(cmd), shell=True)
- if retCode != 0:
- raise PostProcessingError('Command returned error code %d' % retCode)
+ for tmpl in self.exec_cmd:
+ cmd = self.parse_cmd(tmpl, info)
+ self.to_screen('Executing command: %s' % cmd)
+ retCode = subprocess.call(encodeArgument(cmd), shell=True)
+ if retCode != 0:
+ raise PostProcessingError('Command returned error code %d' % retCode)
return [], info