1
0
Fork 0
mirror of https://gitlab.com/dstftw/youtube-dl.git synced 2020-11-16 09:42:26 +00:00

[YoutubeDL] Don't emit ANSI escape codes on Windows

This commit is contained in:
CeruleanSky 2017-06-03 08:14:23 -04:00 committed by Sergey M
parent f129c3f349
commit 4bede0d8f5

View file

@ -498,24 +498,25 @@ class YoutubeDL(object):
def to_console_title(self, message): def to_console_title(self, message):
if not self.params.get('consoletitle', False): if not self.params.get('consoletitle', False):
return return
if compat_os_name == 'nt' and ctypes.windll.kernel32.GetConsoleWindow(): if compat_os_name == 'nt':
# c_wchar_p() might not be necessary if `message` is if ctypes.windll.kernel32.GetConsoleWindow():
# already of type unicode() # c_wchar_p() might not be necessary if `message` is
ctypes.windll.kernel32.SetConsoleTitleW(ctypes.c_wchar_p(message)) # already of type unicode()
ctypes.windll.kernel32.SetConsoleTitleW(ctypes.c_wchar_p(message))
elif 'TERM' in os.environ: elif 'TERM' in os.environ:
self._write_string('\033]0;%s\007' % message, self._screen_file) self._write_string('\033]0;%s\007' % message, self._screen_file)
def save_console_title(self): def save_console_title(self):
if not self.params.get('consoletitle', False): if not self.params.get('consoletitle', False):
return return
if 'TERM' in os.environ: if compat_os_name != 'nt' and 'TERM' in os.environ:
# Save the title on stack # Save the title on stack
self._write_string('\033[22;0t', self._screen_file) self._write_string('\033[22;0t', self._screen_file)
def restore_console_title(self): def restore_console_title(self):
if not self.params.get('consoletitle', False): if not self.params.get('consoletitle', False):
return return
if 'TERM' in os.environ: if compat_os_name != 'nt' and 'TERM' in os.environ:
# Restore the title from stack # Restore the title from stack
self._write_string('\033[23;0t', self._screen_file) self._write_string('\033[23;0t', self._screen_file)