annotate src/core/anime.cc @ 297:1d59a3f72c52

CI: new and improved windows build
author Paper <paper@paper.us.eu.org>
date Mon, 13 May 2024 03:00:10 -0400
parents 53e3c015a973
children 91ac90a34003
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 /*
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 * anime.cpp: defining of custom anime-related
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 * datatypes & variables
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include "core/anime.h"
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
6 #include "core/anime_season.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include "core/date.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
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
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 #include <algorithm>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 #include <string>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 #include <vector>
275
22f9aacf6ac1 osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
14 #include <cassert>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 namespace Anime {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 /* User list data */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 bool Anime::IsInUserList() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
20 if (list_info_.has_value())
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 return true;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 return false;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 void Anime::AddToUserList() {
265
ff0b2052b234 *: add missing utf8proc files
Paper <paper@paper.us.eu.org>
parents: 264
diff changeset
26 ListInformation list;
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
27 list_info_.emplace(list);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 void Anime::RemoveFromUserList() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 list_info_.reset();
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 ListStatus Anime::GetUserStatus() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
35 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 return list_info_->status;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 int Anime::GetUserProgress() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
40 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 return list_info_->progress;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 int Anime::GetUserScore() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
45 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 return list_info_->score;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48
185
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
49 std::string Anime::GetUserPresentableScore() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
50 assert(list_info_.has_value());
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
51
185
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
52 const int score = list_info_->score;
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
53 if (score == 0)
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
54 return "";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
55
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
56 switch (session.config.anime_list.score_format) {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
57 case ScoreFormat::Point10Decimal:
211
7cf53145de11 strings: use templates for ToInt, std::to_string -> Strings::ToUtf8String
Paper <mrpapersonic@gmail.com>
parents: 195
diff changeset
58 return Strings::ToUtf8String(score / 10) + "." + Strings::ToUtf8String(score % 10);
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
59 case ScoreFormat::Point10: return Strings::ToUtf8String(score / 10);
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
60 case ScoreFormat::Point5: {
185
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
61 std::string stars = "";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
62
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
63 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
64 stars.append((i <= score) ? "★" : "☆");
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
65
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
66 return stars;
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
67 }
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
68 case ScoreFormat::Point3: {
185
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
69 if (score >= 100)
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
70 return ":)";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
71 else if (score >= 66)
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
72 return ":|";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
73 else if (score >= 33)
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
74 return ":(";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
75 else
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
76 return "";
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 default:
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
79 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
80 }
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
81 }
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
82
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 Date Anime::GetUserDateStarted() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
84 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85 return list_info_->started;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88 Date Anime::GetUserDateCompleted() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
89 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 return list_info_->completed;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
93 bool Anime::GetUserIsPrivate() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
94 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 return list_info_->is_private;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98 unsigned int Anime::GetUserRewatchedTimes() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
99 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100 return list_info_->rewatched_times;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
102
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 bool Anime::GetUserIsRewatching() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
104 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105 return list_info_->rewatching;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 uint64_t Anime::GetUserTimeUpdated() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
109 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110 return list_info_->updated;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
111 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
112
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
113 std::string Anime::GetUserNotes() const {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
114 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115 return list_info_->notes;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
117
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
118 void Anime::SetUserStatus(ListStatus status) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
119 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
120 list_info_->status = status;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
121 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
122
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
123 void Anime::SetUserScore(int score) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
124 assert(list_info_.has_value());
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
125 list_info_->score = score;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
126 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
127
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
128 void Anime::SetUserProgress(int progress) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
129 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
130 list_info_->progress = progress;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
131 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 void Anime::SetUserDateStarted(Date const& started) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
134 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 list_info_->started = started;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
137
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
138 void Anime::SetUserDateCompleted(Date const& completed) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
139 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140 list_info_->completed = completed;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
141 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
142
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
143 void Anime::SetUserIsPrivate(bool is_private) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
144 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
145 list_info_->is_private = is_private;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
146 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
147
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
148 void Anime::SetUserRewatchedTimes(int rewatched) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
149 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
150 list_info_->rewatched_times = rewatched;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
151 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153 void Anime::SetUserIsRewatching(bool rewatching) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
154 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155 list_info_->rewatching = rewatching;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
156 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
157
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
158 void Anime::SetUserTimeUpdated(uint64_t updated) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
159 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
160 list_info_->updated = updated;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
161 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 void Anime::SetUserNotes(std::string const& notes) {
264
9a04802848c0 *: improve multiple things
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
164 assert(list_info_.has_value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
165 list_info_->notes = notes;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
167
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
168 /* Series data */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
169 int Anime::GetId() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
170 return info_.id;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
171 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
172
286
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
173 std::optional<std::string> Anime::GetServiceId(Service service) const {
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
174 if (info_.ids.find(service) == info_.ids.end())
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
175 return std::nullopt;
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
176
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
177 return info_.ids.at(service);
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
178 }
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
179
284
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
180 /* note: this should use std::optional */
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
181 std::optional<std::string> Anime::GetTitle(TitleLanguage language) const {
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
182 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
183 return std::nullopt;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
184
284
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
185 return info_.titles.at(language);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
186 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
187
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
188 std::vector<std::string> Anime::GetTitleSynonyms() const {
284
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
189 /* mainly for the GUI */
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
190 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
191
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 186
diff changeset
192 auto add_to_synonyms = [this](std::vector<std::string>& vec, std::string key) {
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 186
diff changeset
193 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
194 vec.push_back(key);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 186
diff changeset
195 };
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 186
diff changeset
196
284
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
197 for (const auto& lang : TitleLanguages)
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
198 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
199 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
200
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 186
diff changeset
201 for (auto& synonym : info_.synonyms)
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 186
diff changeset
202 add_to_synonyms(result, synonym);
975a3f0965e2 locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents: 186
diff changeset
203
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
204 return result;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
205 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
206
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
207 int Anime::GetEpisodes() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
208 return info_.episodes;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
209 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
210
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
211 SeriesStatus Anime::GetAiringStatus() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
212 return info_.status;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
213 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
214
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
215 Date Anime::GetAirDate() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
216 return info_.air_date;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
217 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
218
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
219 std::vector<std::string> Anime::GetGenres() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
220 return info_.genres;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
221 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
222
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
223 std::vector<std::string> Anime::GetProducers() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
224 return info_.producers;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
225 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
226
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
227 SeriesFormat Anime::GetFormat() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
228 return info_.format;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
229 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
230
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
231 SeriesSeason Anime::GetSeason() const {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
232 std::optional<Date::Month> month = info_.air_date.GetMonth();
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
233 return (month.has_value() ? GetSeasonForMonth(month.value()) : SeriesSeason::Unknown);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
234 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
235
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
236 int Anime::GetAudienceScore() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
237 return info_.audience_score;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
238 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
239
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
240 std::string Anime::GetSynopsis() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
241 return info_.synopsis;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
242 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
243
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
244 int Anime::GetDuration() const {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
245 return info_.duration;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
246 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
247
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
248 std::string Anime::GetPosterUrl() const {
286
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
249 /* 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
250 * kitsu, MAL, or anilist, and would achieve basically
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
251 * the same effect. */
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
252 return info_.poster_url;
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
253 }
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
254
286
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
255 std::optional<std::string> Anime::GetServiceUrl(Service service) const {
183
01d259b9c89f pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents: 178
diff changeset
256 /* todo: add support for other services... */
286
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
257 std::optional<std::string> id = GetServiceId(service);
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
258 if (!id.has_value())
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
259 return std::nullopt;
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
260
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
261 switch (service) {
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
262 case Service::AniList:
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
263 return "https://anilist.co/anime/" + id.value();
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
264 default: return "";
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 265
diff changeset
265 }
67
442065432549 poster: make posters link to AniList
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
266 }
442065432549 poster: make posters link to AniList
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
267
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
268 void Anime::SetId(int id) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
269 info_.id = id;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
270 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
271
286
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
272 void Anime::SetServiceId(Service service, const std::string& id) {
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
273 info_.ids[service] = id;
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
274 }
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 284
diff changeset
275
284
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
276 void Anime::SetTitle(TitleLanguage language, const std::string& title) {
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
277 info_.titles[language] = title;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
278 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
279
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
280 void Anime::SetTitleSynonyms(std::vector<std::string> const& synonyms) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
281 info_.synonyms = synonyms;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
282 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
283
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
284 void Anime::AddTitleSynonym(std::string const& synonym) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
285 info_.synonyms.push_back(synonym);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
286 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
287
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
288 void Anime::SetEpisodes(int episodes) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
289 info_.episodes = episodes;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
290 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
291
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
292 void Anime::SetAiringStatus(SeriesStatus status) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
293 info_.status = status;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
294 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
295
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
296 void Anime::SetAirDate(Date const& date) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
297 info_.air_date = date;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
298 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
299
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
300 void Anime::SetGenres(std::vector<std::string> const& genres) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
301 info_.genres = genres;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
302 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
303
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
304 void Anime::SetProducers(std::vector<std::string> const& producers) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
305 info_.producers = producers;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
306 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
307
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
308 void Anime::SetFormat(SeriesFormat format) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
309 info_.format = format;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
310 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
311
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
312 void Anime::SetAudienceScore(int audience_score) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
313 info_.audience_score = audience_score;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
314 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
315
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
316 void Anime::SetSynopsis(std::string synopsis) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
317 info_.synopsis = synopsis;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
318 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
319
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
320 void Anime::SetDuration(int duration) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
321 info_.duration = duration;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
322 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
323
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
324 void Anime::SetPosterUrl(std::string url) {
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
325 info_.poster_url = url;
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
326 }
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
327
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
328 std::string Anime::GetUserPreferredTitle() const {
284
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
329 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
330 if (title.has_value())
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
331 return title.value();
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
332
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
333 title = GetTitle(TitleLanguage::Romaji);
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
334 if (title.has_value())
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
335 return title.value();
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
336
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
337 /* what? */
e66ffc338d82 anime: refactor title structure to a map
Paper <paper@paper.us.eu.org>
parents: 280
diff changeset
338 return std::string();
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
339 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
340
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
341 } // namespace Anime