From f95c9ddad1ae5b2f0bc2e07dc768b2c6a97d525f Mon Sep 17 00:00:00 2001 From: kikuyan Date: Thu, 1 Jul 2021 08:20:33 +0900 Subject: [PATCH] feed script to osascript from stdin --- youtube_dl/YoutubeDL.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index c09af2cec..8867a3ada 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -578,13 +578,10 @@ class YoutubeDL(object): 'end repeat', 'end tell' ] - opts = [] - for s in scpt: - opts += ['-e', s] - cmd = ([encodeFilename('osascript', True)] - + [encodeArgument(o) for o in opts]) - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = p.communicate() + scpt = '\n'.join(scpt).encode('utf-8') + cmd = [encodeFilename('osascript', True), encodeArgument('-')] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) + stdout, stderr = p.communicate(input=scpt) if p.returncode == 0: window_title = stdout.decode('utf-8').strip() except EnvironmentError: