Mercurial > minori
comparison src/core/anime_db.cc @ 258:862d0d8619f6
*: HUUUGE changes
animia has been renamed to animone, so instead of thinking of a
health condition, you think of a beautiful flower :)
I've also edited some of the code for animone, but I have no idea
if it even works or not because I don't have a mac or windows
machine lying around. whoops!
... anyway, all of the changes divergent from Anisthesia are now
licensed under BSD. it's possible that I could even rewrite most
of the code to where I don't even have to keep the MIT license,
but that's thinking too far into the future
I've been slacking off on implementing the anime seasons page,
mostly out of laziness. I think I'd have to create another db file
specifically for the seasons
anyway, this code is being pushed *primarily* because the hard drive
it's on is failing! yay :)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 01 Apr 2024 02:43:44 -0400 |
parents | d14f8e0e40c3 |
children | dd211ff68b36 |
comparison
equal
deleted
inserted
replaced
257:699a20c57dc8 | 258:862d0d8619f6 |
---|---|
1 #include "core/anime_db.h" | 1 #include "core/anime_db.h" |
2 #include "core/anime.h" | 2 #include "core/anime.h" |
3 #include "core/filesystem.h" | |
4 #include "core/json.h" | |
3 #include "core/strings.h" | 5 #include "core/strings.h" |
4 #include "core/json.h" | 6 |
5 #include "core/filesystem.h" | 7 #include "gui/translate/anilist.h" |
6 | |
7 #include "gui/translate/anime.h" | 8 #include "gui/translate/anime.h" |
8 #include "gui/translate/anilist.h" | |
9 | 9 |
10 #include <QDate> | 10 #include <QDate> |
11 | 11 |
12 #include <fstream> | 12 #include <fstream> |
13 | 13 |
14 #include <exception> | |
14 #include <iostream> | 15 #include <iostream> |
15 #include <exception> | |
16 | 16 |
17 namespace Anime { | 17 namespace Anime { |
18 | 18 |
19 size_t Database::GetTotalAnimeAmount() { | 19 size_t Database::GetTotalAnimeAmount() { |
20 size_t total = 0; | 20 size_t total = 0; |
53 size_t Database::GetTotalWatchedAmount() { | 53 size_t Database::GetTotalWatchedAmount() { |
54 size_t total = 0; | 54 size_t total = 0; |
55 | 55 |
56 for (const auto& [id, anime] : items) | 56 for (const auto& [id, anime] : items) |
57 if (anime.IsInUserList()) | 57 if (anime.IsInUserList()) |
58 total += anime.GetDuration() * anime.GetUserProgress() | 58 total += anime.GetDuration() * anime.GetUserProgress() + |
59 + anime.GetEpisodes() * anime.GetDuration() * anime.GetUserRewatchedTimes(); | 59 anime.GetEpisodes() * anime.GetDuration() * anime.GetUserRewatchedTimes(); |
60 | 60 |
61 return total; | 61 return total; |
62 } | 62 } |
63 | 63 |
64 /* Returns the total planned amount in minutes. | 64 /* Returns the total planned amount in minutes. |
120 } | 120 } |
121 } | 121 } |
122 return id; | 122 return id; |
123 } | 123 } |
124 | 124 |
125 /* | 125 /* |
126 * TODO: separate this from the anime DB, | 126 * TODO: separate this from the anime DB, |
127 * provide *some* sort of normalization | 127 * provide *some* sort of normalization |
128 */ | 128 */ |
129 int Database::GetAnimeFromTitle(const std::string& title) { | 129 int Database::GetAnimeFromTitle(const std::string& title) { |
130 if (title.empty()) | 130 if (title.empty()) |
131 return 0; | 131 return 0; |
132 | 132 |
133 for (const auto& [id, anime] : items) { | 133 for (const auto& [id, anime] : items) { |
250 anime.SetNativeTitle(JSON::GetString<std::string>(json, "/title/native"_json_pointer, "")); | 250 anime.SetNativeTitle(JSON::GetString<std::string>(json, "/title/native"_json_pointer, "")); |
251 anime.SetRomajiTitle(JSON::GetString<std::string>(json, "/title/romaji"_json_pointer, "")); | 251 anime.SetRomajiTitle(JSON::GetString<std::string>(json, "/title/romaji"_json_pointer, "")); |
252 anime.SetEnglishTitle(JSON::GetString<std::string>(json, "/title/english"_json_pointer, "")); | 252 anime.SetEnglishTitle(JSON::GetString<std::string>(json, "/title/english"_json_pointer, "")); |
253 anime.SetTitleSynonyms(JSON::GetArray<std::vector<std::string>>(json, "/synonyms"_json_pointer, {})); | 253 anime.SetTitleSynonyms(JSON::GetArray<std::vector<std::string>>(json, "/synonyms"_json_pointer, {})); |
254 anime.SetEpisodes(JSON::GetNumber(json, "/episodes"_json_pointer, 0)); | 254 anime.SetEpisodes(JSON::GetNumber(json, "/episodes"_json_pointer, 0)); |
255 anime.SetAiringStatus(Translate::ToSeriesStatus(JSON::GetString<std::string>(json, "/airing_status"_json_pointer, ""))); | 255 anime.SetAiringStatus( |
256 Translate::ToSeriesStatus(JSON::GetString<std::string>(json, "/airing_status"_json_pointer, ""))); | |
256 anime.SetAirDate(Date(JSON::GetValue(json, "/air_date"_json_pointer))); | 257 anime.SetAirDate(Date(JSON::GetValue(json, "/air_date"_json_pointer))); |
257 anime.SetGenres(JSON::GetArray<std::vector<std::string>>(json, "/genres"_json_pointer, {})); | 258 anime.SetGenres(JSON::GetArray<std::vector<std::string>>(json, "/genres"_json_pointer, {})); |
258 anime.SetProducers(JSON::GetArray<std::vector<std::string>>(json, "/producers"_json_pointer, {})); | 259 anime.SetProducers(JSON::GetArray<std::vector<std::string>>(json, "/producers"_json_pointer, {})); |
259 anime.SetFormat(Translate::ToSeriesFormat(JSON::GetString<std::string>(json, "/format"_json_pointer, ""))); | 260 anime.SetFormat(Translate::ToSeriesFormat(JSON::GetString<std::string>(json, "/format"_json_pointer, ""))); |
260 anime.SetSeason(Translate::ToSeriesSeason(JSON::GetString<std::string>(json, "/season"_json_pointer, ""))); | 261 anime.SetSeason(Translate::ToSeriesSeason(JSON::GetString<std::string>(json, "/season"_json_pointer, ""))); |