Use nlohmann::json::count so it works with the version shipped in Debian 10

This commit is contained in:
Daniel Schulte 2020-11-22 23:44:33 +01:00
parent 886e714873
commit acfe00ef21
2 changed files with 5 additions and 5 deletions

View File

@ -410,19 +410,19 @@ int main()
break;
}
}
if(config.contains("apiKey") && config["apiKey"].is_string()) {
if(config.count("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()) {
if(config.count("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()) {
if(elem.count("key") && elem["key"].is_string() && elem.count("value") && elem["value"].is_string()) {
yt_config.extra_headers.emplace(elem["key"], elem["value"]);
}
}
}
if(config.contains("database") && config["database"].is_string()) {
if(config.count("database") && config["database"].is_string()) {
database_filename = config["database"];
}

2
yt.cpp
View File

@ -217,7 +217,7 @@ void Channel::fetch_new_videos(sqlite3 *db, progress_info *info, std::optional<s
if(info)
update_progress(info, processed, results);
if(!abort && response.contains("nextPageToken")) {
if(!abort && response.count("nextPageToken")) {
params["pageToken"] = response["nextPageToken"];
//fprintf(stderr, "Processed %d. Next page...\r\n", processed);
} else {