X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2FYoutubeDL.py;h=20eed96caf6dbb824973a1ba7566d5131a5f4334;hb=2b35c9ef742bf261078ea10c6c0bba848db1a0df;hp=6e5ae44d35920b09d2290bd4f97695060e333397;hpb=ce02ed60f27ea27e66c33af745dc7e716377b46f;p=youtube-dl diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 6e5ae44d3..20eed96ca 100644 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -211,7 +211,26 @@ class YoutubeDL(object): # already of type unicode() ctypes.windll.kernel32.SetConsoleTitleW(ctypes.c_wchar_p(message)) elif 'TERM' in os.environ: - self.to_screen('\033]0;%s\007' % message, skip_eol=True) + write_string(u'\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: + write_string(u'\033[22t', self._screen_file) + + def restore_console_title(self): + if not self.params.get('consoletitle', False): + return + if 'TERM' in os.environ: + write_string(u'\033[23t', self._screen_file) + + def __enter__(self): + self.save_console_title() + return self + + def __exit__(self, *args): + self.restore_console_title() def fixed_template(self): """Checks if the output template is fixed."""