From 881082f2364c2e0e66a0a9abcd7a44b603e700cb Mon Sep 17 00:00:00 2001 From: blankie Date: Sun, 3 Dec 2023 10:48:05 +1100 Subject: [PATCH] Fix "key 'meta' not found" https://social.platypus-sandbox.com/@ashten/AcPl5zVFxeGu7eSKSe --- models.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models.cpp b/models.cpp index 022e1b9..21aa93a 100644 --- a/models.cpp +++ b/models.cpp @@ -74,8 +74,9 @@ void from_json(const json& j, Media& media) { if (!j.at("remote_url").is_null()) { media.remote_url = j["remote_url"].get(); } - if (media.type == "image" || media.type == "video" || media.type == "gifv") { - const json& meta = j.at("meta"); + // .contains() check: https://social.platypus-sandbox.com/@ashten/AcPl5zVFxeGu7eSKSe + if (j.contains("meta") && (media.type == "image" || media.type == "video" || media.type == "gifv")) { + const json& meta = j["meta"]; media.size = meta.at("original").get(); media.preview_size = meta.at("small").get(); }