Mercurial > minori
diff src/services/anilist.cc @ 305:91ac90a34003
core/time: remove Duration class, use regular functions instead
this class was pretty useless anyway
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 19 May 2024 15:56:20 -0400 |
parents | 2115488eb302 |
children | 34347fd2a2de |
line wrap: on
line diff
--- a/src/services/anilist.cc Mon May 13 17:02:35 2024 -0400 +++ b/src/services/anilist.cc Sun May 19 15:56:20 2024 -0400 @@ -136,17 +136,15 @@ } static void ParseTitle(const nlohmann::json& json, Anime::Anime& anime) { - nlohmann::json::json_pointer g = "/native"_json_pointer; - if (json.contains(g) && json[g].is_string()) - anime.SetTitle(Anime::TitleLanguage::Native, json[g]); + static const std::unordered_map<Anime::TitleLanguage, nlohmann::json::json_pointer> map = { + {Anime::TitleLanguage::Native, "/native"_json_pointer}, + {Anime::TitleLanguage::English, "/english"_json_pointer}, + {Anime::TitleLanguage::Romaji, "/romaji"_json_pointer}, + }; - g = "/english"_json_pointer; - if (json.contains(g) && json[g].is_string()) - anime.SetTitle(Anime::TitleLanguage::English, json[g]); - - g = "/romaji"_json_pointer; - if (json.contains(g) && json[g].is_string()) - anime.SetTitle(Anime::TitleLanguage::Romaji, json[g]); + for (const auto& [language, ptr] : map) + if (json.contains(ptr) && json[ptr].is_string()) + anime.SetTitle(language, json[ptr]); } static int ParseMediaJson(const nlohmann::json& json) {