aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-04-22 23:05:05 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2013-04-22 23:05:14 +0200
commit75b5c590a8470b40f5bba869be09393757182ddf (patch)
tree80d65688aff4506cd5e2c03af944ee1fc1ad8344
parent44696667805343a2f60bdec25d8ab9ed90b5963c (diff)
downloadyoutube-dl-75b5c590a8470b40f5bba869be09393757182ddf.tar.xz
Do not read configuration files if explicit arguments are given by a host program (#792)
-rw-r--r--youtube_dl/__init__.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 8ec7435ca..f60fb841e 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -47,7 +47,7 @@ from .FileDownloader import *
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,16 +300,21 @@ def parseOpts(arguments):
parser.add_option_group(authentication)
parser.add_option_group(postproc)
- xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
- if xdg_config_home:
- userConfFile = os.path.join(xdg_config_home, 'youtube-dl.conf')
+ if overrideArguments is not None:
+ opts, args = parser.parse_args(overrideArguments)
+ if opts.verbose:
+ print(u'[debug] Override config: ' + repr(overrideArguments))
else:
- userConfFile = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
- systemConf = _readOptions('/etc/youtube-dl.conf')
- userConf = _readOptions(userConfFile)
- commandLineConf = sys.argv[1:]
- argv = (systemConf + userConf + commandLineConf) if not arguments else arguments
- opts, args = parser.parse_args(argv)
+ xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
+ if xdg_config_home:
+ userConfFile = os.path.join(xdg_config_home, 'youtube-dl.conf')
+ else:
+ userConfFile = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
+ 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:
print(u'[debug] System config: ' + repr(systemConf))