Return an empty channel object if there is no pageInfo item
This usually happens if there are API errors
This commit is contained in:
parent
a6fa67bf5a
commit
d4ff88ab17
5
yt.cpp
5
yt.cpp
|
@ -86,6 +86,11 @@ Channel Channel::add(sqlite3 *db, const std::string &selector, const std::string
|
|||
|
||||
const json response = api_request("https://content.googleapis.com/youtube/v3/channels", params);
|
||||
|
||||
// Error responses dont have pageInfo items
|
||||
if(!response.count("pageInfo")) {
|
||||
return Channel("", "");
|
||||
}
|
||||
|
||||
const json page_info = response["pageInfo"];
|
||||
const bool any_results = page_info["totalResults"] > 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue