1
0
mirror of https://github.com/yt-dlp/yt-dlp synced 2025-07-02 12:02:52 -05:00

Save and restore console title (Fixes #1782)

This commit is contained in:
Philipp Hagemeister
2013-11-17 21:05:14 +01:00
parent ce02ed60f2
commit bdde425cbe
2 changed files with 68 additions and 48 deletions

View File

@ -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)