diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2013-11-17 21:05:14 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2013-11-17 21:10:11 +0100 |
commit | bdde425cbe01329d8c24e18cf0492465abb21411 (patch) | |
tree | 178a0406d71cbc7dfdc61d2fb536eaf972c849df /youtube_dl/YoutubeDL.py | |
parent | ce02ed60f27ea27e66c33af745dc7e716377b46f (diff) |
Save and restore console title (Fixes #1782)
Diffstat (limited to 'youtube_dl/YoutubeDL.py')
-rw-r--r-- | youtube_dl/YoutubeDL.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 6e5ae44d3..4e28f9120 100644 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -213,6 +213,25 @@ class YoutubeDL(object): elif 'TERM' in os.environ: self.to_screen('\033]0;%s\007' % message, skip_eol=True) + def save_console_title(self): + if not self.params.get('consoletitle', False): + return + if 'TERM' in os.environ: + self.to_screen('\033[22t') + + def restore_console_title(self): + if not self.params.get('consoletitle', False): + return + if 'TERM' in os.environ: + self.to_screen('\033[23t') + + 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.""" return (re.search(u'(?u)%\\(.+?\\)s', self.params['outtmpl']) is None) |