summary refs log tree commit diff
diff options
context:
space:
mode:
authorCeruleanSky <CeruleanSky@users.noreply.github.com>2017-06-03 08:14:23 -0400
committerSergey M <dstftw@gmail.com>2017-06-03 19:14:23 +0700
commit4bede0d8f5b6fc8d8e46ee240f808935e03eafa2 (patch)
treefa8964ae022ce8596b13f27819fe0655990bbdf8
parentf129c3f349b41ef8f454d67af761e1c15ad30a92 (diff)
downloadyoutube-dl-4bede0d8f5b6fc8d8e46ee240f808935e03eafa2.tar.gz
youtube-dl-4bede0d8f5b6fc8d8e46ee240f808935e03eafa2.tar.xz
youtube-dl-4bede0d8f5b6fc8d8e46ee240f808935e03eafa2.zip
[YoutubeDL] Don't emit ANSI escape codes on Windows
-rwxr-xr-xyoutube_dl/YoutubeDL.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index 4c33d494a..7efa0c948 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -498,24 +498,25 @@ class YoutubeDL(object):
     def to_console_title(self, message):
         if not self.params.get('consoletitle', False):
             return
-        if compat_os_name == 'nt' and ctypes.windll.kernel32.GetConsoleWindow():
-            # c_wchar_p() might not be necessary if `message` is
-            # already of type unicode()
-            ctypes.windll.kernel32.SetConsoleTitleW(ctypes.c_wchar_p(message))
+        if compat_os_name == 'nt':
+            if ctypes.windll.kernel32.GetConsoleWindow():
+                # c_wchar_p() might not be necessary if `message` is
+                # already of type unicode()
+                ctypes.windll.kernel32.SetConsoleTitleW(ctypes.c_wchar_p(message))
         elif 'TERM' in os.environ:
             self._write_string('\033]0;%s\007' % message, self._screen_file)
 
     def save_console_title(self):
         if not self.params.get('consoletitle', False):
             return
-        if 'TERM' in os.environ:
+        if compat_os_name != 'nt' and 'TERM' in os.environ:
             # Save the title on stack
             self._write_string('\033[22;0t', self._screen_file)
 
     def restore_console_title(self):
         if not self.params.get('consoletitle', False):
             return
-        if 'TERM' in os.environ:
+        if compat_os_name != 'nt' and 'TERM' in os.environ:
             # Restore the title from stack
             self._write_string('\033[23;0t', self._screen_file)