Mercurial > minori
diff 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 |
line wrap: on
line diff
--- a/src/services/anilist.cc Wed Jun 12 19:49:19 2024 -0400 +++ b/src/services/anilist.cc Wed Jun 12 20:42:44 2024 -0400 @@ -51,6 +51,13 @@ " month\n" \ " day\n" \ "}\n" \ + "studios {\n" \ + " edges {\n" \ + " node {\n" \ + " name\n" \ + " }\n" \ + " }\n" \ + "}\n" \ "genres\n" \ "episodes\n" \ "duration\n" \ @@ -193,6 +200,17 @@ anime.SetGenres(JSON::GetArray<std::vector<std::string>>(json, "/genres"_json_pointer, {})); anime.SetTitleSynonyms(JSON::GetArray<std::vector<std::string>>(json, "/synonyms"_json_pointer, {})); + { + std::vector<std::string> producers; + + if (json.contains("/studios/edges"_json_pointer) && json["/studios/edges"_json_pointer].is_array()) + for (const auto& edge : json["/studios/edges"_json_pointer]) + if (edge.contains("/node/name"_json_pointer) && edge["/node/name"_json_pointer].is_string()) + producers.push_back(edge["/node/name"_json_pointer].get<std::string>()); + + anime.SetProducers(producers); + } + return id; }