Fix "key 'small' not found"

https://social.platypus-sandbox.com/@ashten/AcPlHNRnHGzjZMGX56
This commit is contained in:
blankie 2023-12-03 10:50:47 +11:00
parent 881082f236
commit ebc055ee0a
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 7 additions and 2 deletions

View File

@ -76,9 +76,14 @@ void from_json(const json& j, Media& media) {
} }
// .contains() check: https://social.platypus-sandbox.com/@ashten/AcPl5zVFxeGu7eSKSe // .contains() check: https://social.platypus-sandbox.com/@ashten/AcPl5zVFxeGu7eSKSe
if (j.contains("meta") && (media.type == "image" || media.type == "video" || media.type == "gifv")) { if (j.contains("meta") && (media.type == "image" || media.type == "video" || media.type == "gifv")) {
// .contains() checks: https://social.platypus-sandbox.com/@ashten/AcPlHNRnHGzjZMGX56
const json& meta = j["meta"]; const json& meta = j["meta"];
media.size = meta.at("original").get<Size>(); if (meta.contains("original")) {
media.preview_size = meta.at("small").get<Size>(); media.size = meta["original"].get<Size>();
}
if (meta.contains("small")) {
media.preview_size = meta["small"].get<Size>();
}
} }
if (!j.at("description").is_null()) { if (!j.at("description").is_null()) {
media.description = j["description"].get<std::string>(); media.description = j["description"].get<std::string>();