aboutsummaryrefslogtreecommitdiff
path: root/lib/anilist/aniAdvanceSearch.js
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-07-16 22:35:39 +0700
committerFactiven <[email protected]>2023-07-16 22:35:39 +0700
commit1eee181e219dfd993d396ac3169e7aad3dd285eb (patch)
tree23fe54e9c3f8810f3ac9ab6b29070b4f0d4b9d20 /lib/anilist/aniAdvanceSearch.js
parentremoved console.log (diff)
downloadmoopa-1eee181e219dfd993d396ac3169e7aad3dd285eb.tar.xz
moopa-1eee181e219dfd993d396ac3169e7aad3dd285eb.zip
Update v3.6.4
- Added Manga page with a working tracker for AniList user - Added schedule component to home page - Added disqus comment section so you can fight on each other (not recommended) - Added /id and /en route for english and indonesian subs (id route still work in progress)
Diffstat (limited to 'lib/anilist/aniAdvanceSearch.js')
-rw-r--r--lib/anilist/aniAdvanceSearch.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/anilist/aniAdvanceSearch.js b/lib/anilist/aniAdvanceSearch.js
new file mode 100644
index 0000000..bb22ead
--- /dev/null
+++ b/lib/anilist/aniAdvanceSearch.js
@@ -0,0 +1,68 @@
+const advance = `
+ query ($search: String, $type: MediaType, $status: MediaStatus, $season: MediaSeason, $seasonYear: Int, $genres: [String], $tags: [String], $sort: [MediaSort], $page: Int, $perPage: Int) {
+ Page (page: $page, perPage: $perPage) {
+ pageInfo {
+ total
+ currentPage
+ lastPage
+ hasNextPage
+ }
+ media (search: $search, type: $type, status: $status, season: $season, seasonYear: $seasonYear, genre_in: $genres, tag_in: $tags, sort: $sort, isAdult: false) {
+ id
+ title {
+ userPreferred
+ }
+ type
+ episodes
+ status
+ format
+ season
+ seasonYear
+ coverImage {
+ extraLarge
+ color
+ }
+ averageScore
+ isAdult
+ }
+ }
+ }
+`;
+
+export async function aniAdvanceSearch(options = {}) {
+ const {
+ search = null,
+ type = "ANIME",
+ seasonYear = NaN,
+ season = undefined,
+ genres = null,
+ page = 1,
+ perPage = null,
+ sort = "POPULARITY_DESC",
+ } = options;
+ // console.log(page);
+ const response = await fetch("https://graphql.anilist.co/", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ query: advance,
+ variables: {
+ search: search,
+ type: type,
+ seasonYear: seasonYear,
+ season: season,
+ genres: genres,
+ perPage: perPage,
+ sort: sort,
+ page: page,
+ },
+ }),
+ });
+
+ const datas = await response.json();
+ // console.log(datas);
+ const data = datas.data.Page;
+ return data;
+}