diff --git a/models.cpp b/models.cpp index 21aa93a..65c8a1c 100644 --- a/models.cpp +++ b/models.cpp @@ -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(); - media.preview_size = meta.at("small").get(); + if (meta.contains("original")) { + media.size = meta["original"].get(); + } + if (meta.contains("small")) { + media.preview_size = meta["small"].get(); + } } if (!j.at("description").is_null()) { media.description = j["description"].get();