mirror of
https://github.com/blackjack4494/yt-dlc.git
synced 2024-12-25 17:27:36 +00:00
Do not read configuration files if explicit arguments are given by a host program (#792)
This commit is contained in:
parent
4469666780
commit
75b5c590a8
1 changed files with 15 additions and 10 deletions
|
@ -47,7 +47,7 @@ from .FileDownloader import *
|
||||||
from .InfoExtractors import gen_extractors
|
from .InfoExtractors import gen_extractors
|
||||||
from .PostProcessor import *
|
from .PostProcessor import *
|
||||||
|
|
||||||
def parseOpts(arguments):
|
def parseOpts(overrideArguments=None):
|
||||||
def _readOptions(filename_bytes):
|
def _readOptions(filename_bytes):
|
||||||
try:
|
try:
|
||||||
optionf = open(filename_bytes)
|
optionf = open(filename_bytes)
|
||||||
|
@ -300,16 +300,21 @@ def parseOpts(arguments):
|
||||||
parser.add_option_group(authentication)
|
parser.add_option_group(authentication)
|
||||||
parser.add_option_group(postproc)
|
parser.add_option_group(postproc)
|
||||||
|
|
||||||
xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
|
if overrideArguments is not None:
|
||||||
if xdg_config_home:
|
opts, args = parser.parse_args(overrideArguments)
|
||||||
userConfFile = os.path.join(xdg_config_home, 'youtube-dl.conf')
|
if opts.verbose:
|
||||||
|
print(u'[debug] Override config: ' + repr(overrideArguments))
|
||||||
else:
|
else:
|
||||||
userConfFile = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
|
xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
|
||||||
systemConf = _readOptions('/etc/youtube-dl.conf')
|
if xdg_config_home:
|
||||||
userConf = _readOptions(userConfFile)
|
userConfFile = os.path.join(xdg_config_home, 'youtube-dl.conf')
|
||||||
commandLineConf = sys.argv[1:]
|
else:
|
||||||
argv = (systemConf + userConf + commandLineConf) if not arguments else arguments
|
userConfFile = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
|
||||||
opts, args = parser.parse_args(argv)
|
systemConf = _readOptions('/etc/youtube-dl.conf')
|
||||||
|
userConf = _readOptions(userConfFile)
|
||||||
|
commandLineConf = sys.argv[1:]
|
||||||
|
argv = systemConf + userConf + commandLineConf
|
||||||
|
opts, args = parser.parse_args(argv)
|
||||||
|
|
||||||
if opts.verbose:
|
if opts.verbose:
|
||||||
print(u'[debug] System config: ' + repr(systemConf))
|
print(u'[debug] System config: ' + repr(systemConf))
|
||||||
|
|
Loading…
Reference in a new issue