1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-17 15:55:56 +00:00

feed script to osascript from stdin

This commit is contained in:
kikuyan 2021-07-01 08:20:33 +09:00
parent a3da97129e
commit f95c9ddad1

View file

@ -578,13 +578,10 @@ class YoutubeDL(object):
'end repeat', 'end repeat',
'end tell' 'end tell'
] ]
opts = [] scpt = '\n'.join(scpt).encode('utf-8')
for s in scpt: cmd = [encodeFilename('osascript', True), encodeArgument('-')]
opts += ['-e', s] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
cmd = ([encodeFilename('osascript', True)] stdout, stderr = p.communicate(input=scpt)
+ [encodeArgument(o) for o in opts])
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode == 0: if p.returncode == 0:
window_title = stdout.decode('utf-8').strip() window_title = stdout.decode('utf-8').strip()
except EnvironmentError: except EnvironmentError: