Mercurial > minori
comparison src/core/anime_db.cc @ 175:9b10175be389
dep/json: update to v3.11.3
anime/db: save anime list to database, very much untested and likely won't work as intended
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 30 Nov 2023 13:52:26 -0500 |
parents | f88eda79c60a |
children | 121c2d5b321f |
comparison
equal
deleted
inserted
replaced
174:f88eda79c60a | 175:9b10175be389 |
---|---|
232 static bool ParseAnimeUserInfoJSON(const nlohmann::json& json, Anime& anime) { | 232 static bool ParseAnimeUserInfoJSON(const nlohmann::json& json, Anime& anime) { |
233 if (!anime.IsInUserList()) | 233 if (!anime.IsInUserList()) |
234 anime.AddToUserList(); | 234 anime.AddToUserList(); |
235 | 235 |
236 anime.SetUserStatus(Translate::ToListStatus(JSON::GetString<std::string>(json, "/status"_json_pointer, ""))); | 236 anime.SetUserStatus(Translate::ToListStatus(JSON::GetString<std::string>(json, "/status"_json_pointer, ""))); |
237 anime.SetUserStatus(JSON::GetNumber(json, "/progress"_json_pointer, 0)); | 237 anime.SetUserProgress(JSON::GetNumber(json, "/progress"_json_pointer, 0)); |
238 anime.SetUserScore(JSON::GetNumber(json, "/score"_json_pointer, 0)); | 238 anime.SetUserScore(JSON::GetNumber(json, "/score"_json_pointer, 0)); |
239 anime.SetUserDateStarted(Date(JSON::GetValue(json, "/started"_json_pointer))); | 239 anime.SetUserDateStarted(Date(JSON::GetValue(json, "/started"_json_pointer))); |
240 anime.SetUserDateStarted(Date(JSON::GetValue(json, "/completed"_json_pointer))); | 240 anime.SetUserDateStarted(Date(JSON::GetValue(json, "/completed"_json_pointer))); |
241 anime.SetUserIsPrivate(JSON::GetBoolean(json, "/private"_json_pointer, false)); | 241 anime.SetUserIsPrivate(JSON::GetBoolean(json, "/private"_json_pointer, false)); |
242 anime.SetUserRewatchedTimes(JSON::GetNumber(json, "/rewatched_times"_json_pointer, "")); | 242 anime.SetUserRewatchedTimes(JSON::GetNumber(json, "/rewatched_times"_json_pointer, 0)); |
243 anime.SetUserIsRewatching(JSON::GetBoolean(json, "/rewatching"_json_pointer, false)); | 243 anime.SetUserIsRewatching(JSON::GetBoolean(json, "/rewatching"_json_pointer, false)); |
244 anime.SetUserTimeUpdated(JSON::GetNumber(json, "/updated"_json_pointer, 0)); | 244 anime.SetUserTimeUpdated(JSON::GetNumber(json, "/updated"_json_pointer, 0)); |
245 anime.SetUserNotes(JSON::GetString<std::string>(json, "/notes"_json_pointer, "")); | 245 anime.SetUserNotes(JSON::GetString<std::string>(json, "/notes"_json_pointer, "")); |
246 | 246 |
247 return true; | 247 return true; |
258 anime.SetNativeTitle(JSON::GetString<std::string>(json, "/title/native"_json_pointer, "")); | 258 anime.SetNativeTitle(JSON::GetString<std::string>(json, "/title/native"_json_pointer, "")); |
259 anime.SetRomajiTitle(JSON::GetString<std::string>(json, "/title/romaji"_json_pointer, "")); | 259 anime.SetRomajiTitle(JSON::GetString<std::string>(json, "/title/romaji"_json_pointer, "")); |
260 anime.SetEnglishTitle(JSON::GetString<std::string>(json, "/title/english"_json_pointer, "")); | 260 anime.SetEnglishTitle(JSON::GetString<std::string>(json, "/title/english"_json_pointer, "")); |
261 anime.SetTitleSynonyms(JSON::GetArray<std::vector<std::string>>(json, "/synonyms"_json_pointer, {})); | 261 anime.SetTitleSynonyms(JSON::GetArray<std::vector<std::string>>(json, "/synonyms"_json_pointer, {})); |
262 anime.SetEpisodes(JSON::GetNumber(json, "/episodes"_json_pointer, 0)); | 262 anime.SetEpisodes(JSON::GetNumber(json, "/episodes"_json_pointer, 0)); |
263 anime.SetAiringStatus(Translate::AniList::ToSeriesStatus(JSON::GetString<std::string>(json, "/airing_status"_json_pointer, ""))); | 263 anime.SetAiringStatus(Translate::ToSeriesStatus(JSON::GetString<std::string>(json, "/airing_status"_json_pointer, ""))); |
264 anime.SetAirDate(Date(JSON::GetValue(json, "/air_date"_json_pointer))); | 264 anime.SetAirDate(Date(JSON::GetValue(json, "/air_date"_json_pointer))); |
265 anime.SetGenres(JSON::GetArray<std::vector<std::string>>(json, "/genres"_json_pointer, {})); | 265 anime.SetGenres(JSON::GetArray<std::vector<std::string>>(json, "/genres"_json_pointer, {})); |
266 anime.SetProducers(JSON::GetArray<std::vector<std::string>>(json, "/producers"_json_pointer, {})); | 266 anime.SetProducers(JSON::GetArray<std::vector<std::string>>(json, "/producers"_json_pointer, {})); |
267 anime.SetFormat(Translate::AniList::ToSeriesFormat(JSON::GetString<std::string>(json, "/format"_json_pointer, ""))); | 267 anime.SetFormat(Translate::ToSeriesFormat(JSON::GetString<std::string>(json, "/format"_json_pointer, ""))); |
268 anime.SetSeason(Translate::AniList::ToSeriesSeason(JSON::GetString<std::string>(json, "/season"_json_pointer, ""))); | 268 anime.SetSeason(Translate::ToSeriesSeason(JSON::GetString<std::string>(json, "/season"_json_pointer, ""))); |
269 anime.SetAudienceScore(JSON::GetNumber(json, "/audience_score"_json_pointer, 0)); | 269 anime.SetAudienceScore(JSON::GetNumber(json, "/audience_score"_json_pointer, 0)); |
270 anime.SetSynopsis(JSON::GetString<std::string>(json, "/synopsis"_json_pointer, "")); | 270 anime.SetSynopsis(JSON::GetString<std::string>(json, "/synopsis"_json_pointer, "")); |
271 anime.SetDuration(JSON::GetNumber(json, "/duration"_json_pointer, 0)); | 271 anime.SetDuration(JSON::GetNumber(json, "/duration"_json_pointer, 0)); |
272 anime.SetPosterUrl(JSON::GetString<std::string>(json, "/poster_url"_json_pointer, "")); | 272 anime.SetPosterUrl(JSON::GetString<std::string>(json, "/poster_url"_json_pointer, "")); |
273 | 273 |
274 if (json.contains("/list_data") && json.at("/list_data").is_dictionary()) | 274 if (json.contains("/list_data") && json.at("/list_data").is_array()) |
275 ParseAnimeUserInfoJSON(json, anime); | 275 ParseAnimeUserInfoJSON(json, anime); |
276 | 276 |
277 return true; | 277 return true; |
278 } | 278 } |
279 | 279 |