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