0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-04 23:35:04 +00:00

Do not read configuration files if explicit arguments are given by a host program (#792)

This commit is contained in:
Philipp Hagemeister 2013-04-22 23:05:05 +02:00
parent 4469666780
commit 75b5c590a8

View file

@ -47,7 +47,7 @@
from .InfoExtractors import gen_extractors
from .PostProcessor import *
def parseOpts(arguments):
def parseOpts(overrideArguments=None):
def _readOptions(filename_bytes):
try:
optionf = open(filename_bytes)
@ -300,6 +300,11 @@ def _find_term_columns():
parser.add_option_group(authentication)
parser.add_option_group(postproc)
if overrideArguments is not None:
opts, args = parser.parse_args(overrideArguments)
if opts.verbose:
print(u'[debug] Override config: ' + repr(overrideArguments))
else:
xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
if xdg_config_home:
userConfFile = os.path.join(xdg_config_home, 'youtube-dl.conf')
@ -308,7 +313,7 @@ def _find_term_columns():
systemConf = _readOptions('/etc/youtube-dl.conf')
userConf = _readOptions(userConfFile)
commandLineConf = sys.argv[1:]
argv = (systemConf + userConf + commandLineConf) if not arguments else arguments
argv = systemConf + userConf + commandLineConf
opts, args = parser.parse_args(argv)
if opts.verbose: