Fix "key 'meta' not found"

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

View File

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