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