]>
jfr.im git - yt-dlp.git/blob - yt_dlp/postprocessor/execafterdownload.py
336671d14a557dac4ec4f1740695ac5b7c3df78f
1 from __future__
import unicode_literals
5 from .common
import PostProcessor
6 from ..compat
import compat_shlex_quote
13 class ExecAfterDownloadPP(PostProcessor
):
15 def __init__(self
, downloader
, exec_cmd
):
16 super(ExecAfterDownloadPP
, self
).__init
__(downloader
)
17 self
.exec_cmd
= exec_cmd
23 def parse_cmd(self
, cmd
, info
):
24 tmpl
, tmpl_dict
= self
._downloader
.prepare_outtmpl(cmd
, info
)
25 if tmpl_dict
: # if there are no replacements, tmpl_dict = {}
26 return tmpl
% tmpl_dict
28 # If no replacements are found, replace {} for backard compatibility
31 return cmd
.replace('{}', compat_shlex_quote(
32 info
.get('filepath') or info
['_filename']))
35 cmd
= self
.parse_cmd(self
.exec_cmd
, info
)
36 self
.to_screen('Executing command: %s' % cmd
)
37 retCode
= subprocess
.call(encodeArgument(cmd
), shell
=True)
39 raise PostProcessingError('Command returned error code %d' % retCode
)