# HG changeset patch # User Paper # Date 1718239364 14400 # Node ID 8141f409d52ce99c2130a8adcb541af36f8f587f # Parent 1b5c04268d6a9567afcf6f0ad21c9ba563debecf services/anilist: fix getting producers should studios and producers be stored separately? diff -r 1b5c04268d6a -r 8141f409d52c src/services/anilist.cc --- 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>(json, "/genres"_json_pointer, {})); anime.SetTitleSynonyms(JSON::GetArray>(json, "/synonyms"_json_pointer, {})); + { + std::vector 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()); + + anime.SetProducers(producers); + } + return id; } diff -r 1b5c04268d6a -r 8141f409d52c src/services/kitsu.cc --- a/src/services/kitsu.cc Wed Jun 12 19:49:19 2024 -0400 +++ b/src/services/kitsu.cc Wed Jun 12 20:42:44 2024 -0400 @@ -506,7 +506,7 @@ bool RetrieveAnimeMetadata(int id) { /* TODO: the genres should *probably* be a std::optional */ Anime::Anime& anime = Anime::db.items[id]; - if (anime.GetGenres().size() > 0) + if (anime.GetGenres().size() > 0 && anime.GetProducers().size()) return false; std::optional service_id = anime.GetServiceId(Anime::Service::Kitsu);