1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-03-13 23:07:28 +08:00

Add option to ignore config files

This commit is contained in:
Jaime Marquínez Ferrándiz 2013-01-11 16:15:31 +01:00
parent 09f9552b40
commit cca8db9b6c
2 changed files with 14 additions and 5 deletions

View File

@ -29,6 +29,7 @@ which means you can modify it, redistribute it or use it however you like.
--user-agent UA specify a custom user agent
--list-extractors List all supported extractors and the URLs they
would handle
--ignore-config Ignore the configuration files
## Video Selection:
--playlist-start NUMBER playlist video to start at (default is 1)

View File

@ -141,6 +141,8 @@ def parseOpts():
action='store_true', dest='list_extractors',
help='List all supported extractors and the URLs they would handle', default=False)
general.add_option('--test', action='store_true', dest='test', default=False, help=optparse.SUPPRESS_HELP)
general.add_option('--ignore-config', action='store_true',
help="Ignore the configuration files", default=False)
selection.add_option('--playlist-start',
dest='playliststart', metavar='NUMBER', help='playlist video to start at (default is %default)', default=1)
@ -265,12 +267,18 @@ def parseOpts():
parser.add_option_group(authentication)
parser.add_option_group(postproc)
xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
if xdg_config_home:
userConf = os.path.join(xdg_config_home, 'youtube-dl.conf')
opts, args = parser.parse_args(sys.argv[1:])
if not opts.ignore_config:
xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
if xdg_config_home:
userConf = os.path.join(xdg_config_home, 'youtube-dl.conf')
else:
userConf = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
argv = _readOptions('/etc/youtube-dl.conf') + _readOptions(userConf) + sys.argv[1:]
else:
userConf = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
argv = _readOptions('/etc/youtube-dl.conf') + _readOptions(userConf) + sys.argv[1:]
argv = sys.argv[1:]
opts, args = parser.parse_args(argv)
return parser, opts, args