From 39064fc306d380f8524c8b4062e3ea7fc5b16213 Mon Sep 17 00:00:00 2001 From: real-zephex Date: Sun, 17 Mar 2024 09:24:57 +0530 Subject: The anime section is fully server rendered! --- src/app/video/[animeId]/page.js | 88 ++++++++++++++++++----------------------- src/app/video/video.css | 4 +- 2 files changed, 40 insertions(+), 52 deletions(-) (limited to 'src/app/video') diff --git a/src/app/video/[animeId]/page.js b/src/app/video/[animeId]/page.js index 4cd74ce..e8ec670 100644 --- a/src/app/video/[animeId]/page.js +++ b/src/app/video/[animeId]/page.js @@ -1,61 +1,49 @@ -"use client"; - +import { MediaPlayer, MediaProvider } from "@vidstack/react"; +import "@vidstack/react/player/styles/base.css"; +import "@vidstack/react/player/styles/plyr/theme.css"; +import { + PlyrLayout, + plyrLayoutIcons, +} from "@vidstack/react/player/layouts/plyr"; import "../video.css"; -import React, { useState, useEffect } from "react"; -import ReactPlayer from "react-player"; -export default function Video({ params }) { +export default async function Video({ params }) { const id = params.animeId; - const [videoLink, setVideoLink] = useState(null); - const [loading, setLoading] = useState(true); - const [epi, setEpi] = useState(""); - - useEffect(() => { - fetch("https://anime-sensei-api.vercel.app/anime/gogoanime/watch/" + id) - .then((res) => res.json()) - .then((data) => { - const words = id.split("-"); - const last_two = words.slice(-2).join(" "); - const remainingWords = words.slice(0, -2).join(" "); - setEpi([last_two, remainingWords]); - setVideoLink(data.sources[3].url); - setLoading(false); - }) - .catch((error) => { - console.log("Some error occured", error); - setLoading(false); - }); - }, [id]); + const words = id.split("-"); + const last_two = words.slice(-2).join(" "); + const remainingWords = words.slice(0, -2).join(" "); + const data = await getVideoLink(id); + const link = data.sources[3].url; return (
- {loading && ( -

- Loading... +

+

+ {last_two} - {remainingWords}

- )} - {videoLink && ( -
-

- {epi[0]} - {epi[1]} -

- + + -
- )} + +
); } + +async function getVideoLink(id) { + const res = await fetch( + "https://anime-sensei-api.vercel.app/anime/gogoanime/watch/" + id + ); + const data = res.json(); + return data; +} diff --git a/src/app/video/video.css b/src/app/video/video.css index c739968..aab1f54 100644 --- a/src/app/video/video.css +++ b/src/app/video/video.css @@ -6,8 +6,8 @@ width: 50%; } -.video2 video { - border-radius: 5px; +.testPlayer { + border-radius: 10px; } .video2 p { -- cgit v1.2.3