diff options
| author | Factiven <[email protected]> | 2023-10-24 20:27:32 +0700 |
|---|---|---|
| committer | Factiven <[email protected]> | 2023-10-24 20:27:32 +0700 |
| commit | 451e4dffd000169e7113aa3275e4acaf7f1fbbbc (patch) | |
| tree | 035edf0d05e2f6878be745c326935aba3d821636 /pages | |
| parent | Update v4.2.1 (diff) | |
| download | moopa-451e4dffd000169e7113aa3275e4acaf7f1fbbbc.tar.xz moopa-451e4dffd000169e7113aa3275e4acaf7f1fbbbc.zip | |
Update v4.2.2v4.2.2
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/admin/index.js | 4 | ||||
| -rw-r--r-- | pages/api/v2/episode/[id].js | 14 | ||||
| -rw-r--r-- | pages/api/v2/etc/recent/[page].js | 4 | ||||
| -rw-r--r-- | pages/api/v2/info/index.js | 7 | ||||
| -rw-r--r-- | pages/api/v2/source/index.js | 6 | ||||
| -rw-r--r-- | pages/en/anime/[...id].js | 4 | ||||
| -rw-r--r-- | pages/en/anime/watch/[...info].js | 2 | ||||
| -rw-r--r-- | pages/en/manga/read/[...params].js | 17 |
8 files changed, 27 insertions, 31 deletions
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) { |