aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2016-08-02 17:03:26 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2016-08-02 17:03:26 +0200
commit3aa9a73554a43b6dcb7a69a6ff8e8fd02c1e836e (patch)
tree652d9c10586a2796b72e099413473ff003afffe7 /youtube_dl
parent6a9b3b61ea145ac03198bc81a67ee322d42a1bc1 (diff)
[options] Hide --password=secret in verbose output
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/options.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/youtube_dl/options.py b/youtube_dl/options.py
index c4a85b2c0..942d44912 100644
--- a/youtube_dl/options.py
+++ b/youtube_dl/options.py
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
import os.path
import optparse
+import re
import sys
from .downloader.external import list_external_downloaders
@@ -93,8 +94,18 @@ def parseOpts(overrideArguments=None):
setattr(parser.values, option.dest, value.split(','))
def _hide_login_info(opts):
- opts = list(opts)
- for private_opt in ['-p', '--password', '-u', '--username', '--video-password']:
+ PRIVATE_OPTS = ['-p', '--password', '-u', '--username', '--video-password']
+ eqre = re.compile('^(?P<key>' + ('|'.join(re.escape(po) for po in PRIVATE_OPTS)) + ')=.+$')
+
+ def _scrub_eq(o):
+ m = eqre.match(o)
+ if m:
+ return m.group('key') + '=PRIVATE'
+ else:
+ return o
+
+ opts = list(map(_scrub_eq, opts))
+ for private_opt in PRIVATE_OPTS:
try:
i = opts.index(private_opt)
opts[i + 1] = 'PRIVATE'