1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-16 22:26:21 +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 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: