Update GamesDBJSONScraper.cpp

prevent `IsObject` assertion failure during `HasMember` call.
This commit is contained in:
Spongman 2019-02-16 18:07:26 -08:00 committed by GitHub
parent 8878cb0b4c
commit 718eae91fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -322,12 +322,16 @@ void processGame(const Value& game, const Value& boxart, std::vector<ScraperSear
result.mdl.set("players", std::to_string(game["players"].GetInt()));
}
std::string id = std::to_string(getIntOrThrow(game, "id"));
if (boxart["data"].HasMember(id.c_str()))
if (boxart.HasMember("data") && boxart["data"].IsObject())
{
std::string image = getBoxartImage(boxart["data"][id.c_str()]);
result.thumbnailUrl = baseImageUrlThumb + "/" + image;
result.imageUrl = baseImageUrlLarge + "/" + image;
std::string id = std::to_string(getIntOrThrow(game, "id"));
if (boxart["data"].HasMember(id.c_str()))
{
std::string image = getBoxartImage(boxart["data"][id.c_str()]);
result.thumbnailUrl = baseImageUrlThumb + "/" + image;
result.imageUrl = baseImageUrlLarge + "/" + image;
}
}
results.push_back(result);