From be477061e8b7cc74eda8e88611d40e04209a0625 Mon Sep 17 00:00:00 2001 From: bato3 Date: Fri, 27 Jul 2018 14:52:48 +0200 Subject: [PATCH 1/3] Make proxy PRIVATE in verbose --- youtube_dl/YoutubeDL.py | 5 ++++- youtube_dl/options.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 38ba43a97..534f60346 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -2273,7 +2273,10 @@ class YoutubeDL(object): for handler in self._opener.handlers: if hasattr(handler, 'proxies'): proxy_map.update(handler.proxies) - self._write_string('[debug] Proxy map: ' + compat_str(proxy_map) + '\n') + self._write_string('[debug] Proxy map: ' + re.sub( + r'(https?://)(?:(?:[^:/\'"@]+:)?[^@]+)(@)', + r'\1PRIVATE\2', + compat_str(proxy_map)) + '\n') if self.params.get('call_home', False): ipaddr = self.urlopen('https://yt-dl.org/ip').read().decode('utf-8') diff --git a/youtube_dl/options.py b/youtube_dl/options.py index e7d8e8910..efb05b8e9 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -21,7 +21,7 @@ from .version import __version__ def _hide_login_info(opts): - PRIVATE_OPTS = set(['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username']) + PRIVATE_OPTS = set(['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username', '--proxy']) eqre = re.compile('^(?P' + ('|'.join(re.escape(po) for po in PRIVATE_OPTS)) + ')=.+$') def _scrub_eq(o): From 17acc34e461ff4ad904d00beb8552c03062aac4c Mon Sep 17 00:00:00 2001 From: bato3 Date: Sat, 28 Jul 2018 00:47:34 +0200 Subject: [PATCH 2/3] adds support for socks protocols and --geo-veryfication-proxy --- youtube_dl/YoutubeDL.py | 2 +- youtube_dl/options.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 534f60346..b21daadff 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -2274,7 +2274,7 @@ class YoutubeDL(object): if hasattr(handler, 'proxies'): proxy_map.update(handler.proxies) self._write_string('[debug] Proxy map: ' + re.sub( - r'(https?://)(?:(?:[^:/\'"@]+:)?[^@]+)(@)', + r'((?:http|socks5)s?://)(?:(?:[^:@]+:)?[^@]+)(@)', r'\1PRIVATE\2', compat_str(proxy_map)) + '\n') diff --git a/youtube_dl/options.py b/youtube_dl/options.py index efb05b8e9..f11bf13df 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -21,7 +21,7 @@ from .version import __version__ def _hide_login_info(opts): - PRIVATE_OPTS = set(['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username', '--proxy']) + PRIVATE_OPTS = set(['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username', '--proxy', '--geo-verification-proxy']) eqre = re.compile('^(?P' + ('|'.join(re.escape(po) for po in PRIVATE_OPTS)) + ')=.+$') def _scrub_eq(o): From 408fcb89faf37edd28603ea6821e92c885d60b49 Mon Sep 17 00:00:00 2001 From: bato3 Date: Sun, 29 Jul 2018 02:09:01 +0200 Subject: [PATCH 3/3] Remove only login credintails from options --- youtube_dl/YoutubeDL.py | 6 ++---- youtube_dl/options.py | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index b21daadff..c0d269f6d 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -104,6 +104,7 @@ from .postprocessor import ( FFmpegPostProcessor, get_postprocessor, ) +from .options import hide_url_login_info from .version import __version__ if compat_os_name == 'nt': @@ -2273,10 +2274,7 @@ class YoutubeDL(object): for handler in self._opener.handlers: if hasattr(handler, 'proxies'): proxy_map.update(handler.proxies) - self._write_string('[debug] Proxy map: ' + re.sub( - r'((?:http|socks5)s?://)(?:(?:[^:@]+:)?[^@]+)(@)', - r'\1PRIVATE\2', - compat_str(proxy_map)) + '\n') + self._write_string('[debug] Proxy map: ' + hide_url_login_info(compat_str(proxy_map)) + '\n') if self.params.get('call_home', False): ipaddr = self.urlopen('https://yt-dl.org/ip').read().decode('utf-8') diff --git a/youtube_dl/options.py b/youtube_dl/options.py index f11bf13df..0c90b6dd6 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -20,21 +20,37 @@ from .utils import ( 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): - 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' + ('|'.join(re.escape(po) for po in PRIVATE_OPTS)) + ')=.+$') + equre = re.compile('^(?P' + ('|'.join(re.escape(po) for po in URL_PRIVATE_OPTS)) + ')=(?P.+)$') def _scrub_eq(o): m = eqre.match(o) if m: return m.group('key') + '=PRIVATE' else: - return o + m = equre.match(o) + if m: + return m.group('key') + '=' + hide_url_login_info(m.group('url')) + else: + return o opts = list(map(_scrub_eq, opts)) for idx, opt in enumerate(opts): if opt in PRIVATE_OPTS and idx + 1 < len(opts): 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