]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[options] Hide --password=secret in verbose output
authorPhilipp Hagemeister <phihag@phihag.de>
Tue, 2 Aug 2016 15:03:26 +0000 (17:03 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Tue, 2 Aug 2016 15:03:26 +0000 (17:03 +0200)
youtube_dl/options.py

index c4a85b2c09c17eb02123836a2341efc93fb6d283..942d44912659232ad50fc3034b462a96f14cd8ae 100644 (file)
@@ -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'