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