Mercurial > minori
annotate include/core/anime.h @ 327:b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
ToLocalString has also been altered to take in both season
and year because lots of locales actually treat formatting
seasons differently! most notably is Russian which adds a
suffix at the end to notate seasons(??)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 13 Jun 2024 01:49:18 -0400 |
parents | 5d3c9b31aa6e |
children |
rev | line source |
---|---|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
1 #ifndef MINORI_CORE_ANIME_H_ |
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
2 #define MINORI_CORE_ANIME_H_ |
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
3 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
4 #include "core/anime_season.h" |
9 | 5 #include "core/date.h" |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
6 |
9 | 7 #include <array> |
8 #include <map> | |
9 #include <vector> | |
264 | 10 #include <optional> |
9 | 11 |
12 namespace Anime { | |
13 | |
14 enum class ListStatus { | |
279 | 15 NotInList = 0, |
16 Current, | |
17 Completed, | |
18 Paused, | |
19 Dropped, | |
20 Planning | |
21 }; | |
22 | |
23 constexpr std::array<ListStatus, 5> ListStatuses{ | |
24 ListStatus::Current, ListStatus::Completed, ListStatus::Paused, | |
25 ListStatus::Dropped, ListStatus::Planning | |
9 | 26 }; |
27 | |
279 | 28 enum class SeriesStatus { |
29 Unknown = 0, | |
30 Finished, | |
31 Releasing, | |
32 NotYetReleased, | |
33 Cancelled, | |
34 Hiatus | |
35 }; | |
9 | 36 |
279 | 37 constexpr std::array<SeriesStatus, 6> SeriesStatuses{ |
38 SeriesStatus::Unknown, | |
39 SeriesStatus::Finished, | |
40 SeriesStatus::Releasing, | |
41 SeriesStatus::NotYetReleased, | |
42 SeriesStatus::Cancelled, | |
43 SeriesStatus::Hiatus | |
9 | 44 }; |
45 | |
46 enum class SeriesFormat { | |
279 | 47 Unknown = 0, |
48 Tv, | |
49 TvShort, | |
50 Movie, | |
51 Special, | |
52 Ova, | |
53 Ona, | |
54 Music | |
55 }; | |
56 | |
57 constexpr std::array<SeriesFormat, 8> SeriesFormats{ | |
58 SeriesFormat::Unknown, | |
59 SeriesFormat::Tv, | |
60 SeriesFormat::TvShort, | |
61 SeriesFormat::Movie, | |
62 SeriesFormat::Special, | |
63 SeriesFormat::Ova, | |
64 SeriesFormat::Ona, | |
65 SeriesFormat::Music | |
9 | 66 }; |
67 | |
68 enum class TitleLanguage { | |
279 | 69 Romaji, |
70 Native, | |
71 English | |
9 | 72 }; |
73 | |
279 | 74 constexpr std::array<TitleLanguage, 3> TitleLanguages{TitleLanguage::Romaji, TitleLanguage::Native, TitleLanguage::English}; |
75 | |
76 enum class Service { | |
77 None, | |
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
78 AniList, |
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
79 MyAnimeList, |
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
80 Kitsu |
9 | 81 }; |
82 | |
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
83 /* this doesn't include MAL and Kitsu because they aren't really |
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
84 * "valid" services yet. */ |
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
85 constexpr std::array<Service, 3> Services{ |
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
86 Service::AniList, |
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
87 Service::MyAnimeList, |
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
88 Service::Kitsu |
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
89 }; |
279 | 90 |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
91 enum class ScoreFormat { |
279 | 92 Point100, // 0-100 |
93 Point10Decimal, // 0.0-10.0 | |
94 Point10, // 0-10 | |
95 Point5, // 0-5, should be represented in stars | |
96 Point3 // 1-3, should be represented in smileys | |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
97 }; |
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
98 |
279 | 99 constexpr std::array<ScoreFormat, 5> ScoreFormats{ScoreFormat::Point100, ScoreFormat::Point10Decimal, |
100 ScoreFormat::Point10, ScoreFormat::Point5, ScoreFormat::Point3}; | |
189 | 101 |
9 | 102 struct ListInformation { |
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
103 std::string id; |
258 | 104 int progress = 0; |
279 | 105 int score = 0; // this will ALWAYS be in POINT_100 format internally |
106 ListStatus status = ListStatus::NotInList; | |
258 | 107 Date started; |
108 Date completed; | |
109 bool is_private = false; | |
110 unsigned int rewatched_times = 0; | |
111 bool rewatching = false; | |
112 uint64_t updated = 0; | |
113 std::string notes; | |
9 | 114 }; |
115 | |
116 struct SeriesInformation { | |
258 | 117 int id; |
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
118 std::map<Service, std::string> ids; |
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
279
diff
changeset
|
119 std::map<TitleLanguage, std::string> titles; |
258 | 120 std::vector<std::string> synonyms; |
121 int episodes = 0; | |
279 | 122 SeriesStatus status = SeriesStatus::Unknown; |
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
320
diff
changeset
|
123 Date started; |
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
320
diff
changeset
|
124 Date completed; |
258 | 125 std::vector<std::string> genres; |
126 std::vector<std::string> producers; | |
279 | 127 SeriesFormat format = SeriesFormat::Unknown; |
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
128 double audience_score = 0; |
258 | 129 std::string synopsis; |
130 int duration = 0; | |
131 std::string poster_url; | |
9 | 132 }; |
133 | |
134 class Anime { | |
258 | 135 public: |
136 /* User list data */ | |
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
137 std::string GetUserId() const; |
258 | 138 ListStatus GetUserStatus() const; |
139 int GetUserProgress() const; | |
140 int GetUserScore() const; | |
141 std::string GetUserPresentableScore() const; | |
142 Date GetUserDateStarted() const; | |
143 Date GetUserDateCompleted() const; | |
144 bool GetUserIsPrivate() const; | |
145 unsigned int GetUserRewatchedTimes() const; | |
146 bool GetUserIsRewatching() const; | |
147 uint64_t GetUserTimeUpdated() const; | |
148 std::string GetUserNotes() const; | |
9 | 149 |
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
150 void SetUserId(const std::string& id); |
258 | 151 void SetUserStatus(ListStatus status); |
152 void SetUserScore(int score); | |
153 void SetUserProgress(int progress); | |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
154 void SetUserDateStarted(const Date& started); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
155 void SetUserDateCompleted(const Date& completed); |
258 | 156 void SetUserIsPrivate(bool is_private); |
157 void SetUserRewatchedTimes(int rewatched); | |
158 void SetUserIsRewatching(bool rewatching); | |
159 void SetUserTimeUpdated(uint64_t updated); | |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
160 void SetUserNotes(const std::string& notes); |
9 | 161 |
258 | 162 /* Series data */ |
163 int GetId() const; | |
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
164 std::optional<std::string> GetServiceId(Service service) const; |
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
279
diff
changeset
|
165 std::optional<std::string> GetTitle(TitleLanguage language) const; |
258 | 166 std::vector<std::string> GetTitleSynonyms() const; |
167 int GetEpisodes() const; | |
168 SeriesStatus GetAiringStatus() const; | |
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
320
diff
changeset
|
169 Date GetStartedDate() const; |
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
320
diff
changeset
|
170 Date GetCompletedDate() const; |
258 | 171 std::vector<std::string> GetGenres() const; |
172 std::vector<std::string> GetProducers() const; | |
173 SeriesFormat GetFormat() const; | |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
174 Season GetSeason() const; |
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
175 double GetAudienceScore() const; |
258 | 176 std::string GetSynopsis() const; |
177 int GetDuration() const; | |
178 std::string GetPosterUrl() const; | |
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
179 std::optional<std::string> GetServiceUrl(Service service) const; |
9 | 180 |
258 | 181 void SetId(int id); |
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
182 void SetServiceId(Service service, const std::string& id); |
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
279
diff
changeset
|
183 void SetTitle(TitleLanguage language, const std::string& title); |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
184 void SetTitleSynonyms(const std::vector<std::string>& synonyms); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
185 void AddTitleSynonym(const std::string& synonym); |
258 | 186 void SetEpisodes(int episodes); |
187 void SetAiringStatus(SeriesStatus status); | |
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
320
diff
changeset
|
188 void SetStartedDate(const Date& date); |
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
320
diff
changeset
|
189 void SetCompletedDate(const Date& date); |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
190 void SetGenres(const std::vector<std::string>& genres); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
191 void SetProducers(const std::vector<std::string>& producers); |
258 | 192 void SetFormat(SeriesFormat format); |
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
193 void SetAudienceScore(double audience_score); |
258 | 194 void SetSynopsis(std::string synopsis); |
195 void SetDuration(int duration); | |
196 void SetPosterUrl(std::string poster); | |
9 | 197 |
258 | 198 std::string GetUserPreferredTitle() const; |
9 | 199 |
258 | 200 /* User stuff */ |
201 void AddToUserList(); | |
202 bool IsInUserList() const; | |
203 void RemoveFromUserList(); | |
9 | 204 |
258 | 205 private: |
206 SeriesInformation info_; | |
264 | 207 std::optional<struct ListInformation> list_info_ = std::nullopt; |
9 | 208 }; |
209 | |
210 } // namespace Anime | |
211 | |
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
212 #endif // MINORI_CORE_ANIME_H_ |