1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-16 23:35:45 +00:00

avoid phantom windows in osascript

This commit is contained in:
kikuyan 2021-06-30 15:18:44 +09:00
parent 5d67355543
commit 43eef1dcd8

View file

@ -557,7 +557,18 @@ class YoutubeDL(object):
window_title = None
try:
ttyname = os.ttyname(self._screen_file.fileno())
opts = ['-e', 'tell app "Terminal" to get custom title of item 1 of (every window whose tty is "%s")' % ttyname]
scpt = [
'tell app "Terminal"',
'repeat with win in (every window)',
'if tty of win is "%s" then' % ttyname,
'return custom title of win',
'end if',
'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)