Mercurial > minori
diff src/services/anilist.cpp @ 11:fc1bf97c528b
*: use C++11 standard
I've been meaning to do this for a while, but I didn't want to reimplement
the filesystem code. Now we are on C++11 and most compilers from the past 5 centuries should support this now
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 17 Sep 2023 06:14:30 -0400 |
parents | 4b198a111713 |
children | cde8f67a7c7d |
line wrap: on
line diff
--- a/src/services/anilist.cpp Sat Sep 16 02:06:01 2023 -0400 +++ b/src/services/anilist.cpp Sun Sep 17 06:14:30 2023 -0400 @@ -16,6 +16,8 @@ #include <format> #define CLIENT_ID "13706" +using nlohmann::literals::operator "" _json_pointer; + namespace Services::AniList { class Account { @@ -119,17 +121,17 @@ Date ParseDate(const nlohmann::json& json) { Date date; - if (json.contains("/year"_json_pointer) && json["/year"_json_pointer].is_number()) + if (json.contains("/year"_json_pointer) && json.at("/year"_json_pointer).is_number()) date.SetYear(JSON::GetInt(json, "/year"_json_pointer)); else date.VoidYear(); - if (json.contains("/month"_json_pointer) && json["/month"_json_pointer].is_number()) + if (json.contains("/month"_json_pointer) && json.at("/month"_json_pointer).is_number()) date.SetMonth(JSON::GetInt(json, "/month"_json_pointer)); else date.VoidMonth(); - if (json.contains("/day"_json_pointer) && json["/day"_json_pointer].is_number()) + if (json.contains("/day"_json_pointer) && json.at("/day"_json_pointer).is_number()) date.SetDay(JSON::GetInt(json, "/day"_json_pointer)); else date.VoidDay(); @@ -149,7 +151,7 @@ Anime::Anime& anime = Anime::db.items[id]; anime.SetId(id); - ParseTitle(json["/title"_json_pointer], anime); + ParseTitle(json.at("/title"_json_pointer), anime); anime.SetEpisodes(JSON::GetInt(json, "/episodes"_json_pointer)); anime.SetFormat(AniListStringToAnimeFormatMap[JSON::GetString(json, "/format"_json_pointer)]);