1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-04 12:34:53 -04:00

Allow multiple --exec and --exec-before-download

This commit is contained in:
pukkandan
2021-08-07 13:30:55 +05:30
parent 379e44ed3c
commit c681cb5d93
2 changed files with 28 additions and 12 deletions

View File

@@ -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