mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-09-03 00:25:08 +00:00
Pass any field to --exec
using similar syntax to output template
Related: https://github.com/ytdl-org/youtube-dl/issues/28642
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user