diff src/include/anilist.h @ 1:1ae666fdf9e2

*: initial commit
author Paper <mrpapersonic@gmail.com>
date Tue, 08 Aug 2023 19:49:15 -0400
parents
children 23d0d9319a00
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/include/anilist.h	Tue Aug 08 19:49:15 2023 -0400
@@ -0,0 +1,33 @@
+#ifndef __anilist_h
+#define __anilist_h
+#include <curl/curl.h>
+#include "anime.h"
+class AniList {
+	public:
+		int Authorize();
+		int GetUserId(std::string name);
+		int UpdateAnimeList(std::vector<AnimeList>* anime_lists, int id);
+
+	private:
+		static size_t CurlWriteCallback(void *contents, size_t size, size_t nmemb, void *userdata);
+		enum AnimeWatchingStatus ConvertWatchingStatusToEnum(std::string status);
+		enum AnimeAiringStatus ConvertAiringStatusToEnum(std::string status);
+		enum AnimeFormat ConvertFormatToEnum(std::string format);
+		enum AnimeSeason ConvertSeasonToEnum(std::string season);
+		std::string SendRequest(std::string data);
+		CURL* curl;
+		CURLcode res;
+};
+
+/* FIXME: at some point, we have to add a separate Date class (which IIRC
+   Kitsu actually does as well), because the standard library functions do
+   not support any null values. Internally, we could represent null or undefined
+   values as... -1?. Also, anything anime-related should probably be in an
+   Anime namespace. */
+#define ANILIST_DATE_IS_VALID(a) \
+	(a["year"].is_number() && a["month"].is_number() && a["day"].is_number())
+#define ANILIST_DATE_TO_YMD(a) \
+	std::chrono::year_month_day(std::chrono::year(a["year"].get<int>()), \
+								std::chrono::month(a["month"].get<int>()), \
+								std::chrono::day(a["day"].get<int>()))
+#endif // __anilist_h