- if '--config-location' in command_line_conf:
- location = compat_expanduser(opts.config_location)
- if os.path.isdir(location):
- location = os.path.join(location, 'youtube-dlc.conf')
- if not os.path.exists(location):
- parser.error('config-location %s does not exist.' % location)
- custom_conf = _readOptions(location)
- elif '--ignore-config' in command_line_conf:
- pass
- else:
- system_conf = _readOptions('/etc/youtube-dlc.conf')
- if '--ignore-config' not in system_conf:
- user_conf = _readUserConf()
+ if '--ignore-config' in configs['command_line']:
+ return
+ if '--ignore-config' in configs['custom']:
+ return
+
+ def get_portable_path():
+ path = os.path.dirname(sys.argv[0])
+ if os.path.abspath(sys.argv[0]) != os.path.abspath(sys.executable): # Not packaged
+ path = os.path.join(path, '..')
+ return os.path.abspath(path)
+
+ run_path = get_portable_path()
+ configs['portable'] = _readOptions(os.path.join(run_path, 'yt-dlp.conf'), default=None)
+ if configs['portable'] is None:
+ configs['portable'] = _readOptions(os.path.join(run_path, 'youtube-dlc.conf'))
+
+ if '--ignore-config' in configs['portable']:
+ return
+ configs['system'] = _readOptions('/etc/yt-dlp.conf', default=None)
+ if configs['system'] is None:
+ configs['system'] = _readOptions('/etc/youtube-dlc.conf')
+
+ if '--ignore-config' in configs['system']:
+ return
+ configs['user'] = _readUserConf('yt-dlp', default=None)
+ if configs['user'] is None:
+ configs['user'] = _readUserConf('youtube-dlc')
+ if '--ignore-config' in configs['user']:
+ configs['system'] = []