mirror of https://github.com/yt-dlp/yt-dlp
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.
37 lines
920 B
Python
37 lines
920 B
Python
11 years ago
|
from __future__ import unicode_literals
|
||
10 years ago
|
|
||
11 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
|
|
||
|
|
||
11 years ago
|
class ExecAfterDownloadPP(PostProcessor):
|
||
4 years ago
|
|
||
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
|
|
||
4 years ago
|
@classmethod
|
||
|
def pp_key(cls):
|
||
|
return 'Exec'
|
||
|
|
||
11 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
|
|
||
4 years ago
|
self.to_screen('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
|