Mercurial > minori
comparison src/services/anilist.cc @ 279:657fda1b9cac
*: clean up enums
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Fri, 19 Apr 2024 13:24:06 -0400 |
parents | dd211ff68b36 |
children | e66ffc338d82 |
comparison
equal
deleted
inserted
replaced
274:f6a756c19bfb | 279:657fda1b9cac |
---|---|
72 return ret; | 72 return ret; |
73 } | 73 } |
74 | 74 |
75 void ParseListStatus(std::string status, Anime::Anime& anime) { | 75 void ParseListStatus(std::string status, Anime::Anime& anime) { |
76 static const std::unordered_map<std::string, Anime::ListStatus> map = { | 76 static const std::unordered_map<std::string, Anime::ListStatus> map = { |
77 {"CURRENT", Anime::ListStatus::CURRENT }, | 77 {"CURRENT", Anime::ListStatus::Current }, |
78 {"PLANNING", Anime::ListStatus::PLANNING }, | 78 {"PLANNING", Anime::ListStatus::Planning }, |
79 {"COMPLETED", Anime::ListStatus::COMPLETED}, | 79 {"COMPLETED", Anime::ListStatus::Completed}, |
80 {"DROPPED", Anime::ListStatus::DROPPED }, | 80 {"DROPPED", Anime::ListStatus::Dropped }, |
81 {"PAUSED", Anime::ListStatus::PAUSED } | 81 {"PAUSED", Anime::ListStatus::Paused } |
82 }; | 82 }; |
83 | 83 |
84 if (status == "REPEATING") { | 84 if (status == "REPEATING") { |
85 anime.SetUserIsRewatching(true); | 85 anime.SetUserIsRewatching(true); |
86 anime.SetUserStatus(Anime::ListStatus::CURRENT); | 86 anime.SetUserStatus(Anime::ListStatus::Current); |
87 return; | 87 return; |
88 } | 88 } |
89 | 89 |
90 if (map.find(status) == map.end()) { | 90 if (map.find(status) == map.end()) { |
91 anime.SetUserStatus(Anime::ListStatus::NOT_IN_LIST); | 91 anime.SetUserStatus(Anime::ListStatus::NotInList); |
92 return; | 92 return; |
93 } | 93 } |
94 | 94 |
95 anime.SetUserStatus(map.at(status)); | 95 anime.SetUserStatus(map.at(status)); |
96 } | 96 } |
97 | 97 |
98 std::string ListStatusToString(const Anime::Anime& anime) { | 98 std::string ListStatusToString(const Anime::Anime& anime) { |
99 if (anime.GetUserIsRewatching()) | 99 if (anime.GetUserIsRewatching() && anime.GetUserStatus() == Anime::ListStatus::Current) |
100 return "REWATCHING"; | 100 return "REWATCHING"; |
101 | 101 |
102 switch (anime.GetUserStatus()) { | 102 switch (anime.GetUserStatus()) { |
103 case Anime::ListStatus::PLANNING: return "PLANNING"; | 103 case Anime::ListStatus::Planning: return "PLANNING"; |
104 case Anime::ListStatus::COMPLETED: return "COMPLETED"; | 104 case Anime::ListStatus::Completed: return "COMPLETED"; |
105 case Anime::ListStatus::DROPPED: return "DROPPED"; | 105 case Anime::ListStatus::Dropped: return "DROPPED"; |
106 case Anime::ListStatus::PAUSED: return "PAUSED"; | 106 case Anime::ListStatus::Paused: return "PAUSED"; |
107 default: break; | 107 default: break; |
108 } | 108 } |
109 return "CURRENT"; | 109 return "CURRENT"; |
110 } | 110 } |
111 | 111 |
134 anime.SetAirDate(Date(json["/startDate"_json_pointer])); | 134 anime.SetAirDate(Date(json["/startDate"_json_pointer])); |
135 | 135 |
136 anime.SetPosterUrl(JSON::GetString<std::string>(json, "/coverImage/large"_json_pointer, "")); | 136 anime.SetPosterUrl(JSON::GetString<std::string>(json, "/coverImage/large"_json_pointer, "")); |
137 | 137 |
138 anime.SetAudienceScore(JSON::GetNumber(json, "/averageScore"_json_pointer, 0)); | 138 anime.SetAudienceScore(JSON::GetNumber(json, "/averageScore"_json_pointer, 0)); |
139 anime.SetSeason(Translate::AniList::ToSeriesSeason(JSON::GetString<std::string>(json, "/season"_json_pointer, ""))); | 139 // anime.SetSeason(Translate::AniList::ToSeriesSeason(JSON::GetString<std::string>(json, "/season"_json_pointer, ""))); |
140 anime.SetDuration(JSON::GetNumber(json, "/duration"_json_pointer, 0)); | 140 anime.SetDuration(JSON::GetNumber(json, "/duration"_json_pointer, 0)); |
141 | 141 |
142 std::string synopsis = JSON::GetString<std::string>(json, "/description"_json_pointer, ""); | 142 std::string synopsis = JSON::GetString<std::string>(json, "/description"_json_pointer, ""); |
143 Strings::TextifySynopsis(synopsis); | 143 Strings::TextifySynopsis(synopsis); |
144 anime.SetSynopsis(synopsis); | 144 anime.SetSynopsis(synopsis); |