Fix viewing user illustrations
This commit is contained in:
parent
421bbcd6a0
commit
8de4af2972
|
@ -92,7 +92,9 @@ void from_json(const nlohmann::json& j, Illust& illust) {
|
||||||
bool full_data = j.contains("illust_details");
|
bool full_data = j.contains("illust_details");
|
||||||
const nlohmann::json& author_details = j.at("author_details");
|
const nlohmann::json& author_details = j.at("author_details");
|
||||||
const nlohmann::json& illust_details = full_data ? j.at("illust_details") : j;
|
const nlohmann::json& illust_details = full_data ? j.at("illust_details") : j;
|
||||||
const nlohmann::json& images_metadata = illust_details.at("illust_images");
|
std::optional<nlohmann::json> images_metadata = illust_details.contains("illust_images")
|
||||||
|
? std::optional(illust_details["illust_images"])
|
||||||
|
: std::nullopt;
|
||||||
|
|
||||||
author_details.at("user_account").get_to(illust.username);
|
author_details.at("user_account").get_to(illust.username);
|
||||||
author_details.at("user_name").get_to(illust.user_display_name);
|
author_details.at("user_name").get_to(illust.user_display_name);
|
||||||
|
@ -118,10 +120,10 @@ void from_json(const nlohmann::json& j, Illust& illust) {
|
||||||
illust.images.reserve(manga_a.size());
|
illust.images.reserve(manga_a.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < manga_a.size(); i++) {
|
for (size_t i = 0; i < manga_a.size(); i++) {
|
||||||
illust.images.push_back(get_illust_images(manga_a[i], images_metadata.at(i)));
|
illust.images.push_back(get_illust_images(manga_a[i], images_metadata ? std::optional(images_metadata->at(i)) : std::nullopt));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
illust.images = {get_illust_images(illust_details, images_metadata.at(0))};
|
illust.images = {get_illust_images(illust_details, images_metadata ? std::optional(images_metadata->at(0)) : std::nullopt)};
|
||||||
}
|
}
|
||||||
illust.page_count = to_ull(illust_details.at("page_count").get_ref<const nlohmann::json::string_t&>());
|
illust.page_count = to_ull(illust_details.at("page_count").get_ref<const nlohmann::json::string_t&>());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue