Mercurial > minori
comparison src/services/anilist.cc @ 321:8141f409d52c
services/anilist: fix getting producers
should studios and producers be stored separately?
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 12 Jun 2024 20:42:44 -0400 |
parents | 1b5c04268d6a |
children | 1686fac290c5 |
comparison
equal
deleted
inserted
replaced
320:1b5c04268d6a | 321:8141f409d52c |
---|---|
49 "startDate {\n" \ | 49 "startDate {\n" \ |
50 " year\n" \ | 50 " year\n" \ |
51 " month\n" \ | 51 " month\n" \ |
52 " day\n" \ | 52 " day\n" \ |
53 "}\n" \ | 53 "}\n" \ |
54 "studios {\n" \ | |
55 " edges {\n" \ | |
56 " node {\n" \ | |
57 " name\n" \ | |
58 " }\n" \ | |
59 " }\n" \ | |
60 "}\n" \ | |
54 "genres\n" \ | 61 "genres\n" \ |
55 "episodes\n" \ | 62 "episodes\n" \ |
56 "duration\n" \ | 63 "duration\n" \ |
57 "synonyms\n" \ | 64 "synonyms\n" \ |
58 "description(asHtml: false)\n" | 65 "description(asHtml: false)\n" |
190 Strings::TextifySynopsis(synopsis); | 197 Strings::TextifySynopsis(synopsis); |
191 anime.SetSynopsis(synopsis); | 198 anime.SetSynopsis(synopsis); |
192 | 199 |
193 anime.SetGenres(JSON::GetArray<std::vector<std::string>>(json, "/genres"_json_pointer, {})); | 200 anime.SetGenres(JSON::GetArray<std::vector<std::string>>(json, "/genres"_json_pointer, {})); |
194 anime.SetTitleSynonyms(JSON::GetArray<std::vector<std::string>>(json, "/synonyms"_json_pointer, {})); | 201 anime.SetTitleSynonyms(JSON::GetArray<std::vector<std::string>>(json, "/synonyms"_json_pointer, {})); |
202 | |
203 { | |
204 std::vector<std::string> producers; | |
205 | |
206 if (json.contains("/studios/edges"_json_pointer) && json["/studios/edges"_json_pointer].is_array()) | |
207 for (const auto& edge : json["/studios/edges"_json_pointer]) | |
208 if (edge.contains("/node/name"_json_pointer) && edge["/node/name"_json_pointer].is_string()) | |
209 producers.push_back(edge["/node/name"_json_pointer].get<std::string>()); | |
210 | |
211 anime.SetProducers(producers); | |
212 } | |
195 | 213 |
196 return id; | 214 return id; |
197 } | 215 } |
198 | 216 |
199 static int ParseListItem(const nlohmann::json& json) { | 217 static int ParseListItem(const nlohmann::json& json) { |