Mercurial > minori
annotate src/core/anime.cc @ 397:811697ad826a
http: do proper global init/cleanup of libcurl
this is done automagically using RAII
| author | Paper <paper@tflc.us> |
|---|---|
| date | Fri, 07 Nov 2025 08:39:24 -0500 |
| parents | 963047512d34 |
| children |
| rev | line source |
|---|---|
| 9 | 1 /* |
| 2 * anime.cpp: defining of custom anime-related | |
| 3 * datatypes & variables | |
| 4 */ | |
| 5 #include "core/anime.h" | |
| 279 | 6 #include "core/anime_season.h" |
| 9 | 7 #include "core/date.h" |
| 8 #include "core/session.h" | |
|
211
7cf53145de11
strings: use templates for ToInt, std::to_string -> Strings::ToUtf8String
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
9 #include "core/strings.h" |
|
178
bc8d2ccff09c
win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
10 |
| 9 | 11 #include <algorithm> |
| 369 | 12 #include <cassert> |
| 9 | 13 #include <string> |
| 14 #include <vector> | |
| 15 | |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
16 #include <iostream> |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
17 |
| 9 | 18 namespace Anime { |
|
383
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
19 /* FIXME need to parse relations data as well. |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
20 * |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
21 * For example |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
22 * A Certain Magical Index - 2x13.mkv |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
23 * How do we know which anime is the second season of |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
24 * "A Certain Magical Index"? We can't possibly know |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
25 * without relations data! |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
26 * |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
27 * A way to solve this would be to store prequel/sequel. |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
28 * This is sorta-kinda anime speak for seasons. We can |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
29 * then find when the prequels stop. HOWEVER, this isn't |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
30 * exactly fool proof, because there are shows with a |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
31 * second "season" that is actually a prequel, and may |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
32 * show up as one in relations data. So it's not as |
|
27c462bc7815
make the "Now Playing" page actually work
Paper <paper@tflc.us>
parents:
369
diff
changeset
|
33 * straightforward as one may think. */ |
| 9 | 34 |
| 35 /* User list data */ | |
| 369 | 36 bool Anime::IsInUserList() const |
| 37 { | |
| 264 | 38 if (list_info_.has_value()) |
| 9 | 39 return true; |
| 40 return false; | |
| 41 } | |
| 42 | |
| 369 | 43 void Anime::AddToUserList() |
| 44 { | |
|
265
ff0b2052b234
*: add missing utf8proc files
Paper <paper@paper.us.eu.org>
parents:
264
diff
changeset
|
45 ListInformation list; |
| 264 | 46 list_info_.emplace(list); |
| 9 | 47 } |
| 48 | |
| 369 | 49 void Anime::RemoveFromUserList() |
| 50 { | |
| 9 | 51 list_info_.reset(); |
| 52 } | |
| 53 | |
| 369 | 54 std::string Anime::GetUserId() const |
| 55 { | |
|
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
56 assert(list_info_.has_value()); |
|
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
57 return list_info_->id; |
|
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
58 } |
|
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
59 |
| 369 | 60 ListStatus Anime::GetUserStatus() const |
| 61 { | |
| 264 | 62 assert(list_info_.has_value()); |
| 9 | 63 return list_info_->status; |
| 64 } | |
| 65 | |
| 369 | 66 int Anime::GetUserProgress() const |
| 67 { | |
| 264 | 68 assert(list_info_.has_value()); |
| 9 | 69 return list_info_->progress; |
| 70 } | |
| 71 | |
| 369 | 72 int Anime::GetUserScore() const |
| 73 { | |
| 264 | 74 assert(list_info_.has_value()); |
| 9 | 75 return list_info_->score; |
| 76 } | |
| 77 | |
| 369 | 78 std::string Anime::GetUserPresentableScore() const |
| 79 { | |
| 264 | 80 assert(list_info_.has_value()); |
| 279 | 81 |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
82 const int score = list_info_->score; |
|
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
83 if (score == 0) |
|
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
84 return ""; |
|
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
85 |
|
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
86 switch (session.config.anime_list.score_format) { |
| 393 | 87 case ScoreFormat::Point10Decimal: |
| 88 return Strings::ToUtf8String(score / 10) + "." + Strings::ToUtf8String(score % 10); | |
| 89 case ScoreFormat::Point10: | |
| 90 return Strings::ToUtf8String(score / 10); | |
| 91 case ScoreFormat::Point5: { | |
| 92 std::string stars = ""; | |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
93 |
| 393 | 94 for (int i = 0; i < 100; i += 20) |
| 95 stars.append((i <= score) ? "★" : "☆"); | |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
96 |
| 393 | 97 return stars; |
| 98 } | |
| 99 case ScoreFormat::Point3: { | |
| 100 if (score >= 100) | |
| 101 return ":)"; | |
| 102 else if (score >= 66) | |
| 103 return ":|"; | |
| 104 else if (score >= 33) | |
| 105 return ":("; | |
| 106 else | |
| 107 return ""; | |
| 108 } | |
| 109 default: | |
| 110 case ScoreFormat::Point100: | |
| 111 return Strings::ToUtf8String(score); | |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
112 } |
|
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
113 } |
|
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
183
diff
changeset
|
114 |
| 369 | 115 Date Anime::GetUserDateStarted() const |
| 116 { | |
| 264 | 117 assert(list_info_.has_value()); |
| 9 | 118 return list_info_->started; |
| 119 } | |
| 120 | |
| 369 | 121 Date Anime::GetUserDateCompleted() const |
| 122 { | |
| 264 | 123 assert(list_info_.has_value()); |
| 9 | 124 return list_info_->completed; |
| 125 } | |
| 126 | |
| 369 | 127 bool Anime::GetUserIsPrivate() const |
| 128 { | |
| 264 | 129 assert(list_info_.has_value()); |
| 9 | 130 return list_info_->is_private; |
| 131 } | |
| 132 | |
| 369 | 133 unsigned int Anime::GetUserRewatchedTimes() const |
| 134 { | |
| 264 | 135 assert(list_info_.has_value()); |
| 9 | 136 return list_info_->rewatched_times; |
| 137 } | |
| 138 | |
| 369 | 139 bool Anime::GetUserIsRewatching() const |
| 140 { | |
| 264 | 141 assert(list_info_.has_value()); |
| 9 | 142 return list_info_->rewatching; |
| 143 } | |
| 144 | |
| 369 | 145 uint64_t Anime::GetUserTimeUpdated() const |
| 146 { | |
| 264 | 147 assert(list_info_.has_value()); |
| 9 | 148 return list_info_->updated; |
| 149 } | |
| 150 | |
| 369 | 151 std::string Anime::GetUserNotes() const |
| 152 { | |
| 264 | 153 assert(list_info_.has_value()); |
| 9 | 154 return list_info_->notes; |
| 155 } | |
| 156 | |
| 369 | 157 void Anime::SetUserId(const std::string &id) |
| 158 { | |
|
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
159 assert(list_info_.has_value()); |
|
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
160 list_info_->id = id; |
|
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
161 } |
|
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
162 |
| 369 | 163 void Anime::SetUserStatus(ListStatus status) |
| 164 { | |
| 264 | 165 assert(list_info_.has_value()); |
| 9 | 166 list_info_->status = status; |
| 167 } | |
| 168 | |
| 369 | 169 void Anime::SetUserScore(int score) |
| 170 { | |
| 264 | 171 assert(list_info_.has_value()); |
| 10 | 172 list_info_->score = score; |
| 173 } | |
| 174 | |
| 369 | 175 void Anime::SetUserProgress(int progress) |
| 176 { | |
| 264 | 177 assert(list_info_.has_value()); |
| 9 | 178 list_info_->progress = progress; |
| 179 } | |
| 180 | |
| 369 | 181 void Anime::SetUserDateStarted(const Date &started) |
| 182 { | |
| 264 | 183 assert(list_info_.has_value()); |
| 9 | 184 list_info_->started = started; |
| 185 } | |
| 186 | |
| 369 | 187 void Anime::SetUserDateCompleted(const Date &completed) |
| 188 { | |
| 264 | 189 assert(list_info_.has_value()); |
| 9 | 190 list_info_->completed = completed; |
| 191 } | |
| 192 | |
| 369 | 193 void Anime::SetUserIsPrivate(bool is_private) |
| 194 { | |
| 264 | 195 assert(list_info_.has_value()); |
| 9 | 196 list_info_->is_private = is_private; |
| 197 } | |
| 198 | |
| 369 | 199 void Anime::SetUserRewatchedTimes(int rewatched) |
| 200 { | |
| 264 | 201 assert(list_info_.has_value()); |
| 9 | 202 list_info_->rewatched_times = rewatched; |
| 203 } | |
| 204 | |
| 369 | 205 void Anime::SetUserIsRewatching(bool rewatching) |
| 206 { | |
| 264 | 207 assert(list_info_.has_value()); |
| 9 | 208 list_info_->rewatching = rewatching; |
| 209 } | |
| 210 | |
| 369 | 211 void Anime::SetUserTimeUpdated(uint64_t updated) |
| 212 { | |
| 264 | 213 assert(list_info_.has_value()); |
| 9 | 214 list_info_->updated = updated; |
| 215 } | |
| 216 | |
| 369 | 217 void Anime::SetUserNotes(const std::string ¬es) |
| 218 { | |
| 264 | 219 assert(list_info_.has_value()); |
| 9 | 220 list_info_->notes = notes; |
| 221 } | |
| 222 | |
| 223 /* Series data */ | |
| 369 | 224 int Anime::GetId() const |
| 225 { | |
| 9 | 226 return info_.id; |
| 227 } | |
| 228 | |
| 369 | 229 std::optional<std::string> Anime::GetServiceId(Service service) const |
| 230 { | |
|
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
231 if (info_.ids.find(service) == info_.ids.end()) |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
232 return std::nullopt; |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
233 |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
234 return info_.ids.at(service); |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
235 } |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
236 |
|
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
237 /* note: this should use std::optional */ |
| 369 | 238 std::optional<std::string> Anime::GetTitle(TitleLanguage language) const |
| 239 { | |
|
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
240 if (info_.titles.find(language) == info_.titles.end()) |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
241 return std::nullopt; |
| 9 | 242 |
|
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
243 return info_.titles.at(language); |
| 9 | 244 } |
| 245 | |
| 369 | 246 std::vector<std::string> Anime::GetTitleSynonyms() const |
| 247 { | |
|
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
248 /* mainly for the GUI */ |
| 9 | 249 std::vector<std::string> result; |
|
195
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
186
diff
changeset
|
250 |
| 369 | 251 auto add_to_synonyms = [this](std::vector<std::string> &vec, std::string key) { |
|
195
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
186
diff
changeset
|
252 if (!key.empty() && !std::count(vec.begin(), vec.end(), key) && key != GetUserPreferredTitle()) |
|
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
186
diff
changeset
|
253 vec.push_back(key); |
|
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
186
diff
changeset
|
254 }; |
|
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
186
diff
changeset
|
255 |
| 369 | 256 for (const auto &lang : TitleLanguages) |
|
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
257 if (info_.titles.find(lang) != info_.titles.end()) |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
258 add_to_synonyms(result, info_.titles.at(lang)); |
|
195
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
186
diff
changeset
|
259 |
| 369 | 260 for (auto &synonym : info_.synonyms) |
|
195
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
186
diff
changeset
|
261 add_to_synonyms(result, synonym); |
|
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
186
diff
changeset
|
262 |
| 9 | 263 return result; |
| 264 } | |
| 265 | |
| 369 | 266 int Anime::GetEpisodes() const |
| 267 { | |
| 9 | 268 return info_.episodes; |
| 269 } | |
| 270 | |
| 369 | 271 SeriesStatus Anime::GetAiringStatus() const |
| 272 { | |
| 9 | 273 return info_.status; |
| 274 } | |
| 275 | |
| 369 | 276 Date Anime::GetStartedDate() const |
| 277 { | |
|
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
278 return info_.started; |
|
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
279 } |
|
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
280 |
| 369 | 281 Date Anime::GetCompletedDate() const |
| 282 { | |
|
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
283 return info_.completed; |
| 9 | 284 } |
| 285 | |
| 369 | 286 std::vector<std::string> Anime::GetGenres() const |
| 287 { | |
| 9 | 288 return info_.genres; |
| 289 } | |
| 290 | |
| 369 | 291 std::vector<std::string> Anime::GetProducers() const |
| 292 { | |
| 9 | 293 return info_.producers; |
| 294 } | |
| 295 | |
| 369 | 296 SeriesFormat Anime::GetFormat() const |
| 297 { | |
| 9 | 298 return info_.format; |
| 299 } | |
| 300 | |
| 369 | 301 Season Anime::GetSeason() const |
| 302 { | |
|
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
303 return Season(info_.started); |
| 9 | 304 } |
| 305 | |
| 369 | 306 double Anime::GetAudienceScore() const |
| 307 { | |
| 9 | 308 return info_.audience_score; |
| 309 } | |
| 310 | |
| 369 | 311 std::string Anime::GetSynopsis() const |
| 312 { | |
| 9 | 313 return info_.synopsis; |
| 314 } | |
| 315 | |
| 369 | 316 int Anime::GetDuration() const |
| 317 { | |
| 9 | 318 return info_.duration; |
| 319 } | |
| 320 | |
| 369 | 321 std::string Anime::GetPosterUrl() const |
| 322 { | |
|
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
323 /* this isn't really service-specific. this could use |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
324 * kitsu, MAL, or anilist, and would achieve basically |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
325 * the same effect. */ |
|
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
36
diff
changeset
|
326 return info_.poster_url; |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
36
diff
changeset
|
327 } |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
36
diff
changeset
|
328 |
| 369 | 329 std::optional<std::string> Anime::GetServiceUrl(Service service) const |
| 330 { | |
|
183
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
331 /* todo: add support for other services... */ |
|
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
332 std::optional<std::string> id = GetServiceId(service); |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
333 if (!id.has_value()) |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
334 return std::nullopt; |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
335 |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
336 switch (service) { |
| 393 | 337 case Service::AniList: |
| 338 return "https://anilist.co/anime/" + id.value(); | |
| 339 default: | |
| 340 return ""; | |
| 279 | 341 } |
|
67
442065432549
poster: make posters link to AniList
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
342 } |
|
442065432549
poster: make posters link to AniList
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
343 |
| 369 | 344 void Anime::SetId(int id) |
| 345 { | |
| 9 | 346 info_.id = id; |
| 347 } | |
| 348 | |
| 369 | 349 void Anime::SetServiceId(Service service, const std::string &id) |
| 350 { | |
|
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
351 info_.ids[service] = id; |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
352 } |
|
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
284
diff
changeset
|
353 |
| 369 | 354 void Anime::SetTitle(TitleLanguage language, const std::string &title) |
| 355 { | |
|
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
356 info_.titles[language] = title; |
| 9 | 357 } |
| 358 | |
| 369 | 359 void Anime::SetTitleSynonyms(const std::vector<std::string> &synonyms) |
| 360 { | |
| 9 | 361 info_.synonyms = synonyms; |
| 362 } | |
| 363 | |
| 369 | 364 void Anime::AddTitleSynonym(const std::string &synonym) |
| 365 { | |
| 9 | 366 info_.synonyms.push_back(synonym); |
| 367 } | |
| 368 | |
| 369 | 369 void Anime::SetEpisodes(int episodes) |
| 370 { | |
| 9 | 371 info_.episodes = episodes; |
| 372 } | |
| 373 | |
| 369 | 374 void Anime::SetAiringStatus(SeriesStatus status) |
| 375 { | |
| 9 | 376 info_.status = status; |
| 377 } | |
| 378 | |
| 369 | 379 void Anime::SetStartedDate(const Date &date) |
| 380 { | |
|
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
381 info_.started = date; |
| 9 | 382 } |
| 383 | |
| 369 | 384 void Anime::SetCompletedDate(const Date &date) |
| 385 { | |
|
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
386 info_.completed = date; |
|
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
387 } |
|
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
317
diff
changeset
|
388 |
| 369 | 389 void Anime::SetGenres(const std::vector<std::string> &genres) |
| 390 { | |
| 9 | 391 info_.genres = genres; |
| 392 } | |
| 393 | |
| 369 | 394 void Anime::SetProducers(const std::vector<std::string> &producers) |
| 395 { | |
| 9 | 396 info_.producers = producers; |
| 397 } | |
| 398 | |
| 369 | 399 void Anime::SetFormat(SeriesFormat format) |
| 400 { | |
| 9 | 401 info_.format = format; |
| 402 } | |
| 403 | |
| 369 | 404 void Anime::SetAudienceScore(double audience_score) |
| 405 { | |
| 9 | 406 info_.audience_score = audience_score; |
| 407 } | |
| 408 | |
| 369 | 409 void Anime::SetSynopsis(std::string synopsis) |
| 410 { | |
| 9 | 411 info_.synopsis = synopsis; |
| 412 } | |
| 413 | |
| 369 | 414 void Anime::SetDuration(int duration) |
| 415 { | |
| 9 | 416 info_.duration = duration; |
| 417 } | |
| 418 | |
| 369 | 419 void Anime::SetPosterUrl(std::string url) |
| 420 { | |
|
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
36
diff
changeset
|
421 info_.poster_url = url; |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
36
diff
changeset
|
422 } |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
36
diff
changeset
|
423 |
| 369 | 424 std::string Anime::GetUserPreferredTitle() const |
| 425 { | |
|
284
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
426 std::optional<std::string> title = GetTitle(session.config.anime_list.language); |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
427 if (title.has_value()) |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
428 return title.value(); |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
429 |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
430 title = GetTitle(TitleLanguage::Romaji); |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
431 if (title.has_value()) |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
432 return title.value(); |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
433 |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
434 /* what? */ |
|
e66ffc338d82
anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents:
280
diff
changeset
|
435 return std::string(); |
| 9 | 436 } |
| 437 | |
| 438 } // namespace Anime |
