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