diff src/services/kitsu.cc @ 393:963047512d34

*: clang-format
author Paper <paper@tflc.us>
date Fri, 07 Nov 2025 07:16:15 -0500
parents a72d6d7b3568
children de10a647eb9b
line wrap: on
line diff
--- a/src/services/kitsu.cc	Fri Nov 07 07:10:32 2025 -0500
+++ b/src/services/kitsu.cc	Fri Nov 07 07:16:15 2025 -0500
@@ -140,8 +140,7 @@
 
 static std::optional<nlohmann::json> SendJSONAPIRequest(const std::string &path,
                                                         const std::map<std::string, std::string> &params = {},
-                                                        const std::string &data = "",
-                                                        HTTP::Type type = HTTP::Type::Get)
+                                                        const std::string &data = "", HTTP::Type type = HTTP::Type::Get)
 {
 	std::optional<std::string> token = AccountAccessToken();
 	if (!token)
@@ -551,7 +550,7 @@
 	std::map<std::string, std::string> params = anime_params;
 	params["filter[text]"] = search;
 	// ... for some reason, this seems to be buggy
-	//AddAnimeFilters(params);
+	// AddAnimeFilters(params);
 
 	std::optional<nlohmann::json> response = SendJSONAPIRequest("/anime", params);
 	if (!response)
@@ -581,10 +580,10 @@
 bool GetSeason(Anime::Season season)
 {
 	static const std::map<Anime::Season::Name, std::string> map = {
-		{Anime::Season::Name::Winter, "winter"},
-		{Anime::Season::Name::Spring, "spring"},
-		{Anime::Season::Name::Summer, "summer"},
-		{Anime::Season::Name::Autumn, "fall"},
+	    {Anime::Season::Name::Winter, "winter"},
+	    {Anime::Season::Name::Spring, "spring"},
+	    {Anime::Season::Name::Summer, "summer"},
+	    {Anime::Season::Name::Autumn, "fall"  },
 	};
 
 	session.SetStatusBar(Strings::Translate("Kitsu: Retrieving season data..."));
@@ -593,7 +592,7 @@
 	params["filter[season]"] = map.at(season.season);
 	params["filter[seasonYear]"] = Strings::ToUtf8String(season.year);
 	// ... for some reason, this seems to be buggy
-	//AddAnimeFilters(params);
+	// AddAnimeFilters(params);
 
 	std::optional<nlohmann::json> response = SendJSONAPIRequest("/anime", params);
 	if (!response)
@@ -616,11 +615,16 @@
 static std::string UserStatusToString(Anime::ListStatus status)
 {
 	switch (status) {
-		case Anime::ListStatus::Planning: return "planned";
-		case Anime::ListStatus::Completed: return "completed";
-		case Anime::ListStatus::Dropped: return "dropped";
-		case Anime::ListStatus::Paused: return "on_hold";
-		default: break;
+	case Anime::ListStatus::Planning:
+		return "planned";
+	case Anime::ListStatus::Completed:
+		return "completed";
+	case Anime::ListStatus::Dropped:
+		return "dropped";
+	case Anime::ListStatus::Paused:
+		return "on_hold";
+	default:
+		break;
 	}
 
 	return "current";
@@ -635,35 +639,34 @@
 		return 0; /* WTF */
 
 	nlohmann::json json = {
-		{"data", {
-			{"type", "libraryEntries"},
-			{"attributes", {
-				{"status", UserStatusToString(anime.GetUserStatus())},
-				{"progress", anime.GetUserProgress()},
-				{"reconsuming", anime.GetUserIsRewatching()},
-				{"reconsumeCount", anime.GetUserRewatchedTimes()},
-				{"notes", anime.GetUserNotes()},
-				{"private", anime.GetUserIsPrivate()},
-				// WTF is reactionSkipped?
-				{"startedAt", anime.GetUserDateStarted().GetAsISO8601()},
-				{"finishedAt", anime.GetUserDateCompleted().GetAsISO8601()},
-			}},
-			{"relationships", {
-				{"anime", {
-					{"data", {
-						{"type", "anime"},
-						{"id", anime.GetServiceId(Anime::Service::Kitsu)},
-					}}
-				}},
-				{"user", {
-					{"data", {
-						{"type", "users"},
-						{"id", session.config.auth.kitsu.user_id},
-					}}
-				}}
-			}}
-		}}
-	};
+	    {"data",
+	     {{"type", "libraryEntries"},
+	      {"attributes",
+	       {
+	           {"status", UserStatusToString(anime.GetUserStatus())},
+	           {"progress", anime.GetUserProgress()},
+	           {"reconsuming", anime.GetUserIsRewatching()},
+	           {"reconsumeCount", anime.GetUserRewatchedTimes()},
+	           {"notes", anime.GetUserNotes()},
+	           {"private", anime.GetUserIsPrivate()},
+	           // WTF is reactionSkipped?
+	           {"startedAt", anime.GetUserDateStarted().GetAsISO8601()},
+	           {"finishedAt", anime.GetUserDateCompleted().GetAsISO8601()},
+	       }},
+	      {"relationships",
+	       {{"anime",
+	         {{"data",
+	           {
+	               {"type", "anime"},
+	               {"id", anime.GetServiceId(Anime::Service::Kitsu)},
+	           }}}},
+	        {"user",
+	         {{"data",
+	           {
+	               {"type", "users"},
+	               {"id", session.config.auth.kitsu.user_id},
+	           }}}}}}}}
+    };
 
 	nlohmann::json &attributes = json["data"]["attributes"];