Fix "key 'small' not found"
https://social.platypus-sandbox.com/@ashten/AcPlHNRnHGzjZMGX56
This commit is contained in:
parent
881082f236
commit
ebc055ee0a
|
@ -76,9 +76,14 @@ void from_json(const json& j, Media& media) {
|
|||
}
|
||||
// .contains() check: https://social.platypus-sandbox.com/@ashten/AcPl5zVFxeGu7eSKSe
|
||||
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"];
|
||||
media.size = meta.at("original").get<Size>();
|
||||
media.preview_size = meta.at("small").get<Size>();
|
||||
if (meta.contains("original")) {
|
||||
media.size = meta["original"].get<Size>();
|
||||
}
|
||||
if (meta.contains("small")) {
|
||||
media.preview_size = meta["small"].get<Size>();
|
||||
}
|
||||
}
|
||||
if (!j.at("description").is_null()) {
|
||||
media.description = j["description"].get<std::string>();
|
||||
|
|
Loading…
Reference in New Issue