Fix delayed title display in --console-title
authorMantas Mikulėnas <grawity@gmail.com>
Sat, 9 Feb 2013 20:58:12 +0000 (22:58 +0200)
committerMantas Mikulėnas <grawity@gmail.com>
Sat, 9 Feb 2013 20:58:12 +0000 (22:58 +0200)
With Python 3, the titlebar wouldn't get updated for a long time (due to
stderr buffering), and when it did, the title would be shown as b'...'
representation.

youtube_dl/FileDownloader.py

index 49b032a1bb46d75c929c7b65cfdd7aaec86aa7b2..4f51ed8b03dcc8df4872b12a0cb3f91a07fad0d4 100644 (file)
@@ -208,7 +208,7 @@ class FileDownloader(object):
             # already of type unicode()
             ctypes.windll.kernel32.SetConsoleTitleW(ctypes.c_wchar_p(message))
         elif 'TERM' in os.environ:
-            sys.stderr.write('\033]0;%s\007' % message.encode(preferredencoding()))
+            self.to_screen('\033]0;%s\007' % message, skip_eol=True)
 
     def fixed_template(self):
         """Checks if the output template is fixed."""