mirror of https://github.com/yt-dlp/yt-dlp.git
[options] Hide --password=secret in verbose output
This commit is contained in:
parent
6a9b3b61ea
commit
3aa9a73554
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import optparse
|
import optparse
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .downloader.external import list_external_downloaders
|
from .downloader.external import list_external_downloaders
|
||||||
|
@ -93,8 +94,18 @@ def parseOpts(overrideArguments=None):
|
||||||
setattr(parser.values, option.dest, value.split(','))
|
setattr(parser.values, option.dest, value.split(','))
|
||||||
|
|
||||||
def _hide_login_info(opts):
|
def _hide_login_info(opts):
|
||||||
opts = list(opts)
|
PRIVATE_OPTS = ['-p', '--password', '-u', '--username', '--video-password']
|
||||||
for private_opt in ['-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:
|
try:
|
||||||
i = opts.index(private_opt)
|
i = opts.index(private_opt)
|
||||||
opts[i + 1] = 'PRIVATE'
|
opts[i + 1] = 'PRIVATE'
|
||||||
|
|
Loading…
Reference in New Issue