mirror of https://github.com/blackjack4494/yt-dlc
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
877 B
Python
32 lines
877 B
Python
10 years ago
|
from __future__ import unicode_literals
|
||
10 years ago
|
|
||
10 years ago
|
import subprocess
|
||
10 years ago
|
|
||
|
from .common import PostProcessor
|
||
9 years ago
|
from ..compat import compat_shlex_quote
|
||
8 years ago
|
from ..utils import (
|
||
|
encodeArgument,
|
||
|
PostProcessingError,
|
||
|
)
|
||
11 years ago
|
|
||
|
|
||
10 years ago
|
class ExecAfterDownloadPP(PostProcessor):
|
||
10 years ago
|
def __init__(self, downloader, exec_cmd):
|
||
|
super(ExecAfterDownloadPP, self).__init__(downloader)
|
||
10 years ago
|
self.exec_cmd = exec_cmd
|
||
11 years ago
|
|
||
10 years ago
|
def run(self, information):
|
||
10 years ago
|
cmd = self.exec_cmd
|
||
10 years ago
|
if '{}' not in cmd:
|
||
10 years ago
|
cmd += ' {}'
|
||
11 years ago
|
|
||
9 years ago
|
cmd = cmd.replace('{}', compat_shlex_quote(information['filepath']))
|
||
10 years ago
|
|
||
9 years ago
|
self._downloader.to_screen('[exec] Executing command: %s' % cmd)
|
||
8 years ago
|
retCode = subprocess.call(encodeArgument(cmd), shell=True)
|
||
10 years ago
|
if retCode != 0:
|
||
|
raise PostProcessingError(
|
||
|
'Command returned error code %d' % retCode)
|
||
11 years ago
|
|
||
10 years ago
|
return [], information
|