Remove superfluous config object empty check

Empty objects obviously also don't contain the keys we're looking for.
This commit is contained in:
Daniel Schulte 2020-11-22 19:28:51 +01:00
parent 900cb9a3e1
commit baec1fdf2c
1 changed files with 12 additions and 14 deletions

View File

@ -433,22 +433,20 @@ int main()
fprintf(stderr, "Can't read config file %s...\n", config_file.c_str());
}
}
if(!config.empty()) {
if(config.contains("apiKey") && config["apiKey"].is_string()) {
yt_config.api_key = config["apiKey"];
} else {
tui_abort("A YouTube API key is required for this application to function.\n Please provide one in the config file.");
}
if(config.contains("extraHeaders") && config["extraHeaders"].is_array()) {
for(const json &elem: config["extraHeaders"]) {
if(elem.contains("key") && elem["key"].is_string() && elem.contains("value") && elem["value"].is_string()) {
yt_config.extra_headers.emplace(elem["key"], elem["value"]);
}
if(config.contains("apiKey") && config["apiKey"].is_string()) {
yt_config.api_key = config["apiKey"];
} else {
tui_abort("A YouTube API key is required for this application to function.\n Please provide one in the config file.");
}
if(config.contains("extraHeaders") && config["extraHeaders"].is_array()) {
for(const json &elem: config["extraHeaders"]) {
if(elem.contains("key") && elem["key"].is_string() && elem.contains("value") && elem["value"].is_string()) {
yt_config.extra_headers.emplace(elem["key"], elem["value"]);
}
}
if(config.contains("database") && config["database"].is_string()) {
database_filename = config["database"];
}
}
if(config.contains("database") && config["database"].is_string()) {
database_filename = config["database"];
}
SC(sqlite3_open(database_filename.c_str(), &db));