]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/postprocessor/execafterdownload.py
debian/patches: Drop patch included in version 2017.02.07.
[youtubedl] / youtube_dl / postprocessor / execafterdownload.py
1 from __future__ import unicode_literals
2
3 import subprocess
4
5 from .common import PostProcessor
6 from ..compat import compat_shlex_quote
7 from ..utils import PostProcessingError
8
9
10 class ExecAfterDownloadPP(PostProcessor):
11 def __init__(self, downloader, exec_cmd):
12 super(ExecAfterDownloadPP, self).__init__(downloader)
13 self.exec_cmd = exec_cmd
14
15 def run(self, information):
16 cmd = self.exec_cmd
17 if '{}' not in cmd:
18 cmd += ' {}'
19
20 cmd = cmd.replace('{}', compat_shlex_quote(information['filepath']))
21
22 self._downloader.to_screen('[exec] Executing command: %s' % cmd)
23 retCode = subprocess.call(cmd, shell=True)
24 if retCode != 0:
25 raise PostProcessingError(
26 'Command returned error code %d' % retCode)
27
28 return [], information