changeset 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 c32467cd06bb
files src/services/anilist.cc src/services/kitsu.cc
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
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;
 }
 
--- 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<std::string> service_id = anime.GetServiceId(Anime::Service::Kitsu);