From 451e4dffd000169e7113aa3275e4acaf7f1fbbbc Mon Sep 17 00:00:00 2001 From: Factiven Date: Tue, 24 Oct 2023 20:27:32 +0700 Subject: [PATCH] Update v4.2.2 --- lib/anify/info.js | 4 +--- lib/anify/page.js | 4 ++-- lib/anilist/aniAdvanceSearch.js | 11 ++++++----- lib/consumet/manga/getChapters.js | 4 ++-- lib/consumet/manga/getPage.js | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- pages/admin/index.js | 4 ++-- pages/api/v2/episode/[id].js | 14 ++++---------- pages/api/v2/etc/recent/[page].js | 4 ++-- pages/api/v2/info/index.js | 7 ++++--- pages/api/v2/source/index.js | 6 +++--- pages/en/anime/[...id].js | 4 ++-- pages/en/anime/watch/[...info].js | 2 +- pages/en/manga/read/[...params].js | 17 +++++++++-------- public/manifest.json | 12 ++++++++---- release.md | 9 +++++---- 17 files changed, 56 insertions(+), 56 deletions(-) diff --git a/lib/anify/info.js b/lib/anify/info.js index 08d64aa..05159ce 100644 --- a/lib/anify/info.js +++ b/lib/anify/info.js @@ -3,9 +3,7 @@ import { redis } from "../redis"; export async function fetchInfo(id, key) { try { - const { data } = await axios.get( - `https://api.anify.tv/info/${id}?apikey=${key}` - ); + const { data } = await axios.get(`https://api.anify.tv/info/${id}`); return data; } catch (error) { console.error("Error fetching data:", error); diff --git a/lib/anify/page.js b/lib/anify/page.js index 0f0bb93..6362f88 100644 --- a/lib/anify/page.js +++ b/lib/anify/page.js @@ -1,10 +1,10 @@ import { redis } from "../redis"; // Function to fetch new data -async function fetchData(id, chapterNumber, providerId, chapterId, key) { +async function fetchData(id, chapterNumber, providerId, chapterId) { try { const res = await fetch( - `https://api.anify.tv/pages/${id}/${chapterNumber}/${providerId}/${chapterId}&apikey=${key}` + `https://api.anify.tv/pages/${id}/${chapterNumber}/${providerId}/${chapterId}` ); const data = await res.json(); return data; diff --git a/lib/anilist/aniAdvanceSearch.js b/lib/anilist/aniAdvanceSearch.js index cf344b0..7e684af 100644 --- a/lib/anilist/aniAdvanceSearch.js +++ b/lib/anilist/aniAdvanceSearch.js @@ -27,14 +27,15 @@ export async function aniAdvanceSearch({ const response = await fetch("https://api.anify.tv/search-advanced", { method: "POST", body: JSON.stringify({ - type: "manga", - genres: categorizedGenres, + sort: "averageRating", + sortDirection: "DESC", + ...(categorizedGenres && { ...categorizedGenres }), ...(search && { query: search }), ...(page && { page: page }), ...(perPage && { perPage: perPage }), - ...(format && { format: format }), - ...(seasonYear && { year: seasonYear }), - ...(type && { type: type }), + ...(format && { format: [format] }), + ...(seasonYear && { year: Number(seasonYear) }), + ...(type && { type: format === "NOVEL" ? "novel" : type }), }), }); diff --git a/lib/consumet/manga/getChapters.js b/lib/consumet/manga/getChapters.js index 7a19bbc..ee6eabe 100644 --- a/lib/consumet/manga/getChapters.js +++ b/lib/consumet/manga/getChapters.js @@ -1,7 +1,7 @@ let API_URL; -API_URL = process.env.API_URI; +API_URL = process.env.API_URI || null || null; // remove / from the end of the url if it exists -if (API_URL.endsWith("/")) { +if (API_URL && API_URL.endsWith("/")) { API_URL = API_URL.slice(0, -1); } diff --git a/lib/consumet/manga/getPage.js b/lib/consumet/manga/getPage.js index 832c1d7..40f3fc2 100644 --- a/lib/consumet/manga/getPage.js +++ b/lib/consumet/manga/getPage.js @@ -1,7 +1,7 @@ let API_URL; -API_URL = process.env.API_URI; +API_URL = process.env.API_URI || null; // remove / from the end of the url if it exists -if (API_URL.endsWith("/")) { +if (API_URL && API_URL.endsWith("/")) { API_URL = API_URL.slice(0, -1); } diff --git a/package-lock.json b/package-lock.json index 43faac2..0cedc15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "moopa", - "version": "4.2.1", + "version": "4.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "moopa", - "version": "4.2.1", + "version": "4.2.2", "dependencies": { "@apollo/client": "^3.7.3", "@headlessui/react": "^1.7.15", diff --git a/package.json b/package.json index 9d63838..ea3e3a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moopa", - "version": "4.2.1", + "version": "4.2.2", "private": true, "founder": "Factiven", "scripts": { diff --git a/pages/admin/index.js b/pages/admin/index.js index 2a73fc1..6cb9a76 100644 --- a/pages/admin/index.js +++ b/pages/admin/index.js @@ -29,8 +29,8 @@ export async function getServerSideProps(context) { const admin = sessions?.user?.name === process.env.ADMIN_USERNAME; let api; - api = process.env.API_URI; - if (api.endsWith("/")) { + api = process.env.API_URI || null; + if (api && api.endsWith("/")) { api = api.slice(0, -1); } diff --git a/pages/api/v2/episode/[id].js b/pages/api/v2/episode/[id].js index 029d131..ea511e6 100644 --- a/pages/api/v2/episode/[id].js +++ b/pages/api/v2/episode/[id].js @@ -4,8 +4,8 @@ import appendMetaToEpisodes from "@/utils/appendMetaToEpisodes"; let CONSUMET_URI; -CONSUMET_URI = process.env.API_URI; -if (CONSUMET_URI.endsWith("/")) { +CONSUMET_URI = process.env.API_URI || null; +if (CONSUMET_URI && CONSUMET_URI.endsWith("/")) { CONSUMET_URI = CONSUMET_URI.slice(0, -1); } @@ -96,13 +96,7 @@ async function fetchConsumet(id) { async function fetchAnify(id) { try { - if (!process.env.API_KEY) { - return []; - } - - const { data } = await axios.get( - `https://api.anify.tv/episodes/${id}?apikey=${API_KEY}` - ); + const { data } = await axios.get(`https://api.anify.tv/episodes/${id}`); if (!data) { return []; @@ -138,7 +132,7 @@ async function fetchCoverImage(id, available = false) { } const { data } = await axios.get( - `https://api.anify.tv/content-metadata/${id}?apikey=${API_KEY}` + `https://api.anify.tv/content-metadata/${id}` ); if (!data) { diff --git a/pages/api/v2/etc/recent/[page].js b/pages/api/v2/etc/recent/[page].js index b1bda0f..e21c38e 100644 --- a/pages/api/v2/etc/recent/[page].js +++ b/pages/api/v2/etc/recent/[page].js @@ -1,8 +1,8 @@ import { rateLimiterRedis, redis } from "@/lib/redis"; let API_URL; -API_URL = process.env.API_URI; -if (API_URL.endsWith("/")) { +API_URL = process.env.API_URI || null; +if (API_URL && API_URL.endsWith("/")) { API_URL = API_URL.slice(0, -1); } diff --git a/pages/api/v2/info/index.js b/pages/api/v2/info/index.js index 39795d3..4bebfae 100644 --- a/pages/api/v2/info/index.js +++ b/pages/api/v2/info/index.js @@ -7,7 +7,7 @@ export async function fetchInfo(id) { try { // console.log(id); const { data } = await axios - .get(`https://api.anify.tv/info/${id}?apikey=${API_KEY}`) + .get(`https://api.anify.tv/info/${id}`) .catch((err) => { return { data: null, @@ -19,7 +19,7 @@ export async function fetchInfo(id) { } const { data: Chapters } = await axios.get( - `https://api.anify.tv/chapters/${data.id}?apikey=${API_KEY}` + `https://api.anify.tv/chapters/${data.id}` ); if (!Chapters) { @@ -53,7 +53,8 @@ export default async function handler(req, res) { return res.status(404).json({ error: "Manga not found" }); } - if (redis) await redis.set(`manga:${id}`, JSON.stringify(manga), "ex", 60 * 60 * 24); + if (redis) + await redis.set(`manga:${id}`, JSON.stringify(manga), "ex", 60 * 60 * 24); res.status(200).json(manga); } catch (error) { diff --git a/pages/api/v2/source/index.js b/pages/api/v2/source/index.js index 9ec6082..103bc29 100644 --- a/pages/api/v2/source/index.js +++ b/pages/api/v2/source/index.js @@ -2,8 +2,8 @@ import { rateLimiterRedis, redis } from "@/lib/redis"; import axios from "axios"; let CONSUMET_URI; -CONSUMET_URI = process.env.API_URI; -if (CONSUMET_URI.endsWith("/")) { +CONSUMET_URI = process.env.API_URI || null; +if (CONSUMET_URI && CONSUMET_URI.endsWith("/")) { CONSUMET_URI = CONSUMET_URI.slice(0, -1); } const API_KEY = process.env.API_KEY; @@ -25,7 +25,7 @@ async function anifySource(providerId, watchId, episode, id, sub) { const { data } = await axios.get( `https://api.anify.tv/sources?providerId=${providerId}&watchId=${encodeURIComponent( watchId - )}&episodeNumber=${episode}&id=${id}&subType=${sub}&apikey=${API_KEY}` + )}&episodeNumber=${episode}&id=${id}&subType=${sub}` ); return data; } catch (error) { diff --git a/pages/en/anime/[...id].js b/pages/en/anime/[...id].js index e2c0039..25cc4d6 100644 --- a/pages/en/anime/[...id].js +++ b/pages/en/anime/[...id].js @@ -212,8 +212,8 @@ export async function getServerSideProps(ctx) { const { id } = ctx.query; let API_URI; - API_URI = process.env.API_URI; - if (API_URI.endsWith("/")) { + API_URI = process.env.API_URI || null || null; + if (API_URI && API_URI.endsWith("/")) { API_URI = API_URI.slice(0, -1); } diff --git a/pages/en/anime/watch/[...info].js b/pages/en/anime/watch/[...info].js index 2427669..beab366 100644 --- a/pages/en/anime/watch/[...info].js +++ b/pages/en/anime/watch/[...info].js @@ -31,7 +31,7 @@ export async function getServerSideProps(context) { let proxy; proxy = process.env.PROXY_URI; - if (proxy.endsWith("/")) { + if (proxy && proxy.endsWith("/")) { proxy = proxy.slice(0, -1); } const disqus = process.env.DISQUS_SHORTNAME; diff --git a/pages/en/manga/read/[...params].js b/pages/en/manga/read/[...params].js index 1076601..a7fa78b 100644 --- a/pages/en/manga/read/[...params].js +++ b/pages/en/manga/read/[...params].js @@ -276,7 +276,7 @@ async function fetchAnifyPages(id, number, provider, readId, key) { try { let cached; - cached = await redis.get(`pages:${readId}`); + if (redis) cached = await redis.get(`pages:${readId}`); if (cached) { return JSON.parse(cached); @@ -292,12 +292,13 @@ async function fetchAnifyPages(id, number, provider, readId, key) { return null; } - await redis.set( - `pages:${readId}`, - JSON.stringify(data), - "EX", - 60 * 60 * 24 * 7 - ); + if (redis) + await redis.set( + `pages:${readId}`, + JSON.stringify(data), + "EX", + 60 * 60 * 24 * 7 + ); return data; } catch (error) { @@ -357,7 +358,7 @@ export async function getServerSideProps(context) { } const chapters = await ( - await fetch("https://api.anify.tv/chapters/" + mediaId + "?apikey=" + key) + await fetch("https://api.anify.tv/chapters/" + mediaId) ).json(); if ((dataManga && dataManga?.error) || dataManga?.length === 0) { diff --git a/public/manifest.json b/public/manifest.json index 6505617..cd77de2 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -11,22 +11,26 @@ { "src": "/icon-192x192.png", "sizes": "192x192", - "type": "image/png" + "type": "image/png", + "purpose": "maskable" }, { "src": "/icon-256x256.png", "sizes": "256x256", - "type": "image/png" + "type": "image/png", + "purpose": "maskable" }, { "src": "/icon-384x384.png", "sizes": "384x384", - "type": "image/png" + "type": "image/png", + "purpose": "maskable" }, { "src": "/icon-512x512.png", "sizes": "512x512", - "type": "image/png" + "type": "image/png", + "purpose": "maskable" } ] } diff --git a/release.md b/release.md index 3fa2d2a..73b024c 100644 --- a/release.md +++ b/release.md @@ -2,10 +2,11 @@ This document contains a summary of all significant changes made to this release. -## 🎉 Update v4.2.1 +## 🎉 Update v4.2.2 ### What's Changed -- fix: disqus showing the same comment on every episodes -- fix(premid): discord presence not working properly -- Increased releasing anime episodes cache time to 1 hour +- fix: anify doesn't return anything +- fix: non-consumet user recieve error when parsing the API url +- fix: manga doesn't work without redis +- fix: fixed some functionality when searching manga