aboutsummaryrefslogtreecommitdiff
path: root/pages/en/manga
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-08-09 15:11:53 +0700
committerGitHub <[email protected]>2023-08-09 15:11:53 +0700
commitbae1f53877c3447d3ba940f823e5a8a097f5b22c (patch)
tree98abb195bcad6f3e6c61c76c62fc238f227b0ead /pages/en/manga
parentUpdate package-lock.json (diff)
downloadmoopa-3.9.0.tar.xz
moopa-3.9.0.zip
Update v3.9.0 - Merged Beta to Main (#41)v3.9.0
* initial commit * Update_v.3.6.7-beta-v1.2 * Update_v.3.6.7-beta-v1.3 * Update_v.3.6.7-beta-v1.3 > update API * Fixed mediaList won't update * added .env disqus shortname * Update_v3.6.7-beta-v1.4 >Implementing database * Create main.yml * Update v3.6.7-beta-v1.5 small patch * title home page * Update content.js * Delete db-test.js * Update content.js * Update home page card * Update v3.7.0 * Update v3.7.1-beta > migrating backend to main code > fixed schedule component * Update v3.8.0 > Added dub options > Moved schedule backend * Update v.3.8.1 > Fixed episodes on watch page isn't dubbed * Update v3.8.1-patch-1 * Update v3.8.1-patch-2 > Another patch for dub * Update v3.8.2 > Removed prisma configuration for database since it's not stable yet * Update v3.8.3 > Fixed different provider have same id * Update v.3.8.3 > Fixed player bug where the controls won't hide after updating anilist progress * Update v3.8.4-patch-2 * Update v3.8.5 > Update readme.md > Update .env.example * Update next.config.js * small adjusment info page * Update v3.8.6 > Minor update for Android 13 user * Update v3.8.7 > Added prev and next button to mediaSession * Update v3.8.7-beta-v2 * Beta v2 (#37) * Update schema.prisma * Update schema.prisma * Update schema.prisma * Update 3.9.0-beta-v2.1 > Implemented database for storing user Watch List and settings > Added buttons to auto-play next episodes * Update v3.9.0-beta-v2.2 * Update README.md --------- Co-authored-by: Chitraksh Maheshwari <[email protected]>
Diffstat (limited to 'pages/en/manga')
-rw-r--r--pages/en/manga/[id].js24
-rw-r--r--pages/en/manga/read/[...params].js15
2 files changed, 9 insertions, 30 deletions
diff --git a/pages/en/manga/[id].js b/pages/en/manga/[id].js
index eb53a93..bb3cbc2 100644
--- a/pages/en/manga/[id].js
+++ b/pages/en/manga/[id].js
@@ -9,12 +9,12 @@ import { useEffect, useState } from "react";
import { setCookie } from "nookies";
import { getServerSession } from "next-auth";
import { authOptions } from "../../api/auth/[...nextauth]";
+import getAnifyInfo from "../../../lib/anify/info";
export default function Manga({ info, userManga, chapters }) {
const [domainUrl, setDomainUrl] = useState("");
const [firstEp, setFirstEp] = useState();
- const chaptersData =
- info.chapters.data.length === 0 ? chapters : info.chapters.data;
+ const chaptersData = info.chapters.data;
useEffect(() => {
setDomainUrl(window.location.origin);
@@ -84,8 +84,7 @@ export async function getServerSideProps(context) {
const { id } = context.query;
const key = process.env.API_KEY;
- const res = await fetch(`https://api.anify.tv/info/${id}?apikey=${key}`);
- const data = await res.json();
+ const data = await getAnifyInfo(id, key);
let userManga = null;
@@ -152,27 +151,10 @@ export async function getServerSideProps(context) {
};
}
- let chapter = null;
-
- if (data?.chapters?.data.length === 0) {
- const res2 = await fetch(
- `https://api.anify.tv/chapters/${id}?apikey=${key}`
- );
- const data2 = await res2.json();
- if (data2.error) {
- return {
- notFound: true
- }
- } else {
- chapter = data2;
- }
- }
-
return {
props: {
info: data,
userManga,
- chapters: chapter || null,
},
};
}
diff --git a/pages/en/manga/read/[...params].js b/pages/en/manga/read/[...params].js
index dbabb3d..e608d16 100644
--- a/pages/en/manga/read/[...params].js
+++ b/pages/en/manga/read/[...params].js
@@ -15,6 +15,7 @@ import Head from "next/head";
import nookies from "nookies";
import ShortCutModal from "../../../../components/manga/modals/shortcutModal";
import ChapterModal from "../../../../components/manga/modals/chapterModal";
+import getAnifyPage from "../../../../lib/anify/page";
export default function Read({ data, currentId, sessions }) {
const [info, setInfo] = useState();
@@ -228,6 +229,8 @@ export async function getServerSideProps(context) {
const cookies = nookies.get(context);
+ const key = process.env.API_KEY;
+
const query = context.query;
const providerId = query.params[0];
const chapterId = query.chapterId;
@@ -243,18 +246,12 @@ export async function getServerSideProps(context) {
const session = await getServerSession(context.req, context.res, authOptions);
- const key = process.env.API_KEY;
- const res = await fetch(
- `https://api.anify.tv/pages?providerId=${providerId}&readId=${encodeURIComponent(
- chapterId
- )}&apikey=${key}`
- );
+ const data = await getAnifyPage(mediaId, providerId, chapterId, key);
- const data = await res.json();
if (data.error) {
return {
- notFound: true
- }
+ notFound: true,
+ };
}
return {