annotate src/core/anime.cc @ 328:71396ecb6f7e

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