mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-27 06:10:38 +01:00
Save and restore console title (Fixes #1782)
This commit is contained in:
parent
ce02ed60f2
commit
bdde425cbe
|
@ -213,6 +213,25 @@ class YoutubeDL(object):
|
||||||
elif 'TERM' in os.environ:
|
elif 'TERM' in os.environ:
|
||||||
self.to_screen('\033]0;%s\007' % message, skip_eol=True)
|
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):
|
def fixed_template(self):
|
||||||
"""Checks if the output template is fixed."""
|
"""Checks if the output template is fixed."""
|
||||||
return (re.search(u'(?u)%\\(.+?\\)s', self.params['outtmpl']) is None)
|
return (re.search(u'(?u)%\\(.+?\\)s', self.params['outtmpl']) is None)
|
||||||
|
|
|
@ -603,8 +603,7 @@ def _real_main(argv=None):
|
||||||
u' file! Use "%%(ext)s" instead of %r' %
|
u' file! Use "%%(ext)s" instead of %r' %
|
||||||
determine_ext(outtmpl, u''))
|
determine_ext(outtmpl, u''))
|
||||||
|
|
||||||
# YoutubeDL
|
ydl_opts = {
|
||||||
ydl = YoutubeDL({
|
|
||||||
'usenetrc': opts.usenetrc,
|
'usenetrc': opts.usenetrc,
|
||||||
'username': opts.username,
|
'username': opts.username,
|
||||||
'password': opts.password,
|
'password': opts.password,
|
||||||
|
@ -667,8 +666,9 @@ def _real_main(argv=None):
|
||||||
'youtube_print_sig_code': opts.youtube_print_sig_code,
|
'youtube_print_sig_code': opts.youtube_print_sig_code,
|
||||||
'age_limit': opts.age_limit,
|
'age_limit': opts.age_limit,
|
||||||
'download_archive': opts.download_archive,
|
'download_archive': opts.download_archive,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
with YoutubeDL(ydl_opts) as ydl:
|
||||||
if opts.verbose:
|
if opts.verbose:
|
||||||
write_string(u'[debug] youtube-dl version ' + __version__ + u'\n')
|
write_string(u'[debug] youtube-dl version ' + __version__ + u'\n')
|
||||||
try:
|
try:
|
||||||
|
@ -685,7 +685,8 @@ def _real_main(argv=None):
|
||||||
sys.exc_clear()
|
sys.exc_clear()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
write_string(u'[debug] Python version %s - %s' %(platform.python_version(), platform_name()) + u'\n')
|
write_string(u'[debug] Python version %s - %s' %
|
||||||
|
(platform.python_version(), platform_name()) + u'\n')
|
||||||
|
|
||||||
proxy_map = {}
|
proxy_map = {}
|
||||||
for handler in opener.handlers:
|
for handler in opener.handlers:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user