Add option --config-location
A configfile can now be passed to youtube_dl. undo changes Raise parser error if file not found, change to user_conf change metavar hand helptext for --configfile Fix help for --configfile Update help for --configfile Numbering placeholder in configfile error msg minor fix Change option --configfile top --config-file Fix -config-file error
This commit is contained in:
		| @@ -405,6 +405,7 @@ def _real_main(argv=None): | |||||||
|         'postprocessor_args': postprocessor_args, |         'postprocessor_args': postprocessor_args, | ||||||
|         'cn_verification_proxy': opts.cn_verification_proxy, |         'cn_verification_proxy': opts.cn_verification_proxy, | ||||||
|         'geo_verification_proxy': opts.geo_verification_proxy, |         'geo_verification_proxy': opts.geo_verification_proxy, | ||||||
|  |         'configfile': opts.configfile, | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -178,6 +178,10 @@ def parseOpts(overrideArguments=None): | |||||||
|         'When given in the global configuration file /etc/youtube-dl.conf: ' |         'When given in the global configuration file /etc/youtube-dl.conf: ' | ||||||
|         'Do not read the user configuration in ~/.config/youtube-dl/config ' |         'Do not read the user configuration in ~/.config/youtube-dl/config ' | ||||||
|         '(%APPDATA%/youtube-dl/config.txt on Windows)') |         '(%APPDATA%/youtube-dl/config.txt on Windows)') | ||||||
|  |     general.add_option( | ||||||
|  |         '--config-file', | ||||||
|  |         dest='configfile', metavar='FILE', | ||||||
|  |         help='File to read configuration from.') | ||||||
|     general.add_option( |     general.add_option( | ||||||
|         '--flat-playlist', |         '--flat-playlist', | ||||||
|         action='store_const', dest='extract_flat', const='in_playlist', |         action='store_const', dest='extract_flat', const='in_playlist', | ||||||
| @@ -845,19 +849,29 @@ def parseOpts(overrideArguments=None): | |||||||
|             return conf |             return conf | ||||||
|  |  | ||||||
|         command_line_conf = compat_conf(sys.argv[1:]) |         command_line_conf = compat_conf(sys.argv[1:]) | ||||||
|  |         opts, args = parser.parse_args(command_line_conf) | ||||||
|  |  | ||||||
|         if '--ignore-config' in command_line_conf: |         if '--ignore-config' in command_line_conf: | ||||||
|             system_conf = [] |             system_conf = [] | ||||||
|             user_conf = [] |             user_conf = [] | ||||||
|  |         elif '--config-file' in command_line_conf: | ||||||
|  |             if not os.path.isfile(opts.configfile): | ||||||
|  |                 parser.error('Config file {0} not found.'.format(opts.configfile)) | ||||||
|  |             else: | ||||||
|  |                 user_conf = _readOptions(opts.configfile) | ||||||
|  |                 system_conf = [] | ||||||
|  |  | ||||||
|         else: |         else: | ||||||
|             system_conf = _readOptions('/etc/youtube-dl.conf') |             system_conf = _readOptions('/etc/youtube-dl.conf') | ||||||
|             if '--ignore-config' in system_conf: |             if '--ignore-config' in system_conf: | ||||||
|                 user_conf = [] |                 user_conf = [] | ||||||
|             else: |             else: | ||||||
|                 user_conf = _readUserConf() |                 user_conf = _readUserConf() | ||||||
|  |  | ||||||
|         argv = system_conf + user_conf + command_line_conf |         argv = system_conf + user_conf + command_line_conf | ||||||
|  |  | ||||||
|         opts, args = parser.parse_args(argv) |         opts, args = parser.parse_args(argv) | ||||||
|  |  | ||||||
|         if opts.verbose: |         if opts.verbose: | ||||||
|             write_string('[debug] System config: ' + repr(_hide_login_info(system_conf)) + '\n') |             write_string('[debug] System config: ' + repr(_hide_login_info(system_conf)) + '\n') | ||||||
|             write_string('[debug] User config: ' + repr(_hide_login_info(user_conf)) + '\n') |             write_string('[debug] User config: ' + repr(_hide_login_info(user_conf)) + '\n') | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Fabian Stahl
					Fabian Stahl