Added preliminary support for updating YoutubeDL-Material

Config items that are not found use and set the default value

Fixed potential error while updated youtube-dl binaries
This commit is contained in:
Isaac Grynsztein
2020-03-30 18:35:44 -04:00
parent bcff631936
commit df11aca1e0
4 changed files with 203 additions and 9 deletions

View File

@@ -68,10 +68,16 @@ function setConfigFile(config) {
function getConfigItem(key) {
let config_json = getConfigFile();
if (!CONFIG_ITEMS[key]) {
console.log('cannot find config with key ' + key);
console.log(`ERROR: Config item with key '${key}' is not recognized.`);
return null;
}
let path = CONFIG_ITEMS[key]['path'];
const val = Object.byString(config_json, path);
if (val === undefined && Object.byString(DEFAULT_CONFIG, path)) {
console.log(`WARNING: Cannot find config with key '${key}'. Creating one with the default value...`);
setConfigItem(key, Object.byString(DEFAULT_CONFIG, path));
return Object.byString(DEFAULT_CONFIG, path);
}
return Object.byString(config_json, path);
};