diff options
| author | Factiven <[email protected]> | 2023-09-13 00:45:53 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-13 00:45:53 +0700 |
| commit | 7327a69b55a20b99b14ee0803d6cf5f8b88c45ef (patch) | |
| tree | cbcca777593a8cc4b0282e7d85a6fc51ba517e25 /lib/anilist/getUpcomingAnime.js | |
| parent | Update issue templates (diff) | |
| download | moopa-7327a69b55a20b99b14ee0803d6cf5f8b88c45ef.tar.xz moopa-7327a69b55a20b99b14ee0803d6cf5f8b88c45ef.zip | |
Update v4 - Merge pre-push to main (#71)
* Create build-test.yml
* initial v4 commit
* update: github workflow
* update: push on branch
* Update .github/ISSUE_TEMPLATE/bug_report.md
* configuring next.config.js file
Diffstat (limited to 'lib/anilist/getUpcomingAnime.js')
| -rw-r--r-- | lib/anilist/getUpcomingAnime.js | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/lib/anilist/getUpcomingAnime.js b/lib/anilist/getUpcomingAnime.js index fc848fd..2ab9315 100644 --- a/lib/anilist/getUpcomingAnime.js +++ b/lib/anilist/getUpcomingAnime.js @@ -19,23 +19,39 @@ const getUpcomingAnime = async () => { } const query = ` - query ($season: MediaSeason, $seasonYear: Int) { - Page(page: 1, perPage: 20) { - media(season: $season, seasonYear: $seasonYear, sort: POPULARITY_DESC, type: ANIME) { + query ($season: MediaSeason, $year: Int, $format: MediaFormat, $excludeFormat: MediaFormat, $status: MediaStatus, $minEpisodes: Int, $page: Int) { + Page(page: $page) { + pageInfo { + hasNextPage + total + } + media(season: $season, seasonYear: $year, format: $format, format_not: $excludeFormat, status: $status, episodes_greater: $minEpisodes, isAdult: false, type: ANIME, sort: TITLE_ROMAJI) { id - coverImage{ - large - } - bannerImage + idMal title { - english romaji native + english + } + startDate { + year + month + day + } + status + season + format + description + bannerImage + coverImage { + extraLarge + color } - nextAiringEpisode { - episode - airingAt - timeUntilAiring + airingSchedule(notYetAired: true, perPage: 1) { + nodes { + episode + airingAt + } } } } @@ -43,8 +59,9 @@ const getUpcomingAnime = async () => { `; const variables = { - season: currentSeason, - seasonYear: currentYear, + season: "FALL", + year: currentYear, + format: "TV", }; let response = await fetch("https://graphql.anilist.co", { @@ -63,13 +80,14 @@ const getUpcomingAnime = async () => { let currentSeasonAnime = json.data.Page.media; let nextAiringAnime = currentSeasonAnime.filter( - (anime) => - anime.nextAiringEpisode !== null && anime.nextAiringEpisode.episode === 1 + (anime) => anime.airingSchedule.nodes?.[0]?.episode === 1 ); if (nextAiringAnime.length >= 1) { nextAiringAnime.sort( - (a, b) => a.nextAiringEpisode.airingAt - b.nextAiringEpisode.airingAt + (a, b) => + a.airingSchedule.nodes?.[0].airingAt - + b.airingSchedule.nodes?.[0].airingAt ); return nextAiringAnime; // return all upcoming anime, not just the first two } |