1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-23 00:54:31 +01:00

Remove only login credintails from options

This commit is contained in:
bato3 2018-07-29 02:09:01 +02:00
parent 17acc34e46
commit 408fcb89fa
2 changed files with 20 additions and 6 deletions

View File

@ -104,6 +104,7 @@ from .postprocessor import (
FFmpegPostProcessor, FFmpegPostProcessor,
get_postprocessor, get_postprocessor,
) )
from .options import hide_url_login_info
from .version import __version__ from .version import __version__
if compat_os_name == 'nt': if compat_os_name == 'nt':
@ -2273,10 +2274,7 @@ class YoutubeDL(object):
for handler in self._opener.handlers: for handler in self._opener.handlers:
if hasattr(handler, 'proxies'): if hasattr(handler, 'proxies'):
proxy_map.update(handler.proxies) proxy_map.update(handler.proxies)
self._write_string('[debug] Proxy map: ' + re.sub( self._write_string('[debug] Proxy map: ' + hide_url_login_info(compat_str(proxy_map)) + '\n')
r'((?:http|socks5)s?://)(?:(?:[^:@]+:)?[^@]+)(@)',
r'\1PRIVATE\2',
compat_str(proxy_map)) + '\n')
if self.params.get('call_home', False): if self.params.get('call_home', False):
ipaddr = self.urlopen('https://yt-dl.org/ip').read().decode('utf-8') ipaddr = self.urlopen('https://yt-dl.org/ip').read().decode('utf-8')

View File

@ -20,14 +20,27 @@ from .utils import (
from .version import __version__ from .version import __version__
def hide_url_login_info(url):
return re.sub(
r'((?:http|socks5)s?://)(?:(?:[^:@]+:)?[^@]+)(@)',
r'\1PRIVATE\2', url)
def _hide_login_info(opts): def _hide_login_info(opts):
PRIVATE_OPTS = set(['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username', '--proxy', '--geo-verification-proxy']) PRIVATE_OPTS = set(['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username'])
URL_PRIVATE_OPTS = set(['--proxy', '--geo-verification-proxy'])
eqre = re.compile('^(?P<key>' + ('|'.join(re.escape(po) for po in PRIVATE_OPTS)) + ')=.+$') eqre = re.compile('^(?P<key>' + ('|'.join(re.escape(po) for po in PRIVATE_OPTS)) + ')=.+$')
equre = re.compile('^(?P<key>' + ('|'.join(re.escape(po) for po in URL_PRIVATE_OPTS)) + ')=(?P<url>.+)$')
def _scrub_eq(o): def _scrub_eq(o):
m = eqre.match(o) m = eqre.match(o)
if m: if m:
return m.group('key') + '=PRIVATE' return m.group('key') + '=PRIVATE'
else:
m = equre.match(o)
if m:
return m.group('key') + '=' + hide_url_login_info(m.group('url'))
else: else:
return o return o
@ -35,6 +48,9 @@ def _hide_login_info(opts):
for idx, opt in enumerate(opts): for idx, opt in enumerate(opts):
if opt in PRIVATE_OPTS and idx + 1 < len(opts): if opt in PRIVATE_OPTS and idx + 1 < len(opts):
opts[idx + 1] = 'PRIVATE' opts[idx + 1] = 'PRIVATE'
else:
if opt in URL_PRIVATE_OPTS and idx + 1 < len(opts):
opts[idx + 1] = hide_url_login_info(opts[idx + 1])
return opts return opts