From 9a9e892a1f43a61188cfd08ef1faaf5100d0a41a Mon Sep 17 00:00:00 2001 From: Factiven Date: Mon, 17 Apr 2023 16:17:45 +0700 Subject: 4th fixes --- pages/anime/watch/[...info].js | 70 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 4 deletions(-) (limited to 'pages/anime/watch') diff --git a/pages/anime/watch/[...info].js b/pages/anime/watch/[...info].js index e7195d6..ba3a078 100644 --- a/pages/anime/watch/[...info].js +++ b/pages/anime/watch/[...info].js @@ -423,11 +423,73 @@ export async function getServerSideProps(context) { .filter((item) => item.id == id) .map((item) => item.number); - const resp = await fetch( - `https://moopa-anilist.vercel.app/api/get-media?username=${query.user}` - ); + const response = await fetch("https://graphql.anilist.co/", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + query: ` + query ($username: String, $status: MediaListStatus) { + MediaListCollection(userName: $username, type: ANIME, status: $status, sort: SCORE_DESC) { + user { + id + name + about (asHtml: true) + createdAt + avatar { + large + } + statistics { + anime { + count + episodesWatched + meanScore + minutesWatched + } + } + bannerImage + mediaListOptions { + animeList { + sectionOrder + } + } + } + lists { + status + name + entries { + id + mediaId + status + progress + score + media { + id + status + title { + english + romaji + } + episodes + coverImage { + large + } + } + } + } + } + } + `, + variables: { + username: session?.user.name, + }, + }), + }); + + const dat = await response.json(); - const prog = await resp.json(); + const prog = dat.data.MediaListCollection; const gat = prog?.lists.map((item) => item.entries); const git = gat?.map((item) => -- cgit v1.2.3