aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFactiven <[email protected]>2024-01-11 14:23:15 +0700
committerFactiven <[email protected]>2024-01-11 14:23:15 +0700
commite9aea5ffe32cf43ae0ac0f3d692ea6c9202bc579 (patch)
tree0f792b478c2dfa20ddad0f20abb9a82b1024817f
parentfeat: Add PreviousEpisode and NextEpisode to media controls (#111) (diff)
downloadmoopa-e9aea5ffe32cf43ae0ac0f3d692ea6c9202bc579.tar.xz
moopa-e9aea5ffe32cf43ae0ac0f3d692ea6c9202bc579.zip
Add getRemovedMedia function and handle redirect for removed media
-rw-r--r--.gitignore1
-rw-r--r--pages/en/anime/watch/[...info].js15
-rw-r--r--pages/en/removed.tsx50
-rw-r--r--prisma/removed.ts10
-rw-r--r--prisma/schema.prisma6
5 files changed, 81 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 74d05ef..9bbbc26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ docker-compose.yml
/backup
release-template.md
.vscode
+pnpm-lock.yaml
# debug
npm-debug.log*
diff --git a/pages/en/anime/watch/[...info].js b/pages/en/anime/watch/[...info].js
index 259ebee..0f8dff9 100644
--- a/pages/en/anime/watch/[...info].js
+++ b/pages/en/anime/watch/[...info].js
@@ -5,7 +5,7 @@ import EpisodeLists from "@/components/watch/secondary/episodeLists";
import { getServerSession } from "next-auth";
import { useWatchProvider } from "@/lib/context/watchPageProvider";
import { authOptions } from "../../../api/auth/[...nextauth]";
-import { useAniList } from "@/lib/anilist/useAnilist";
+import { getRemovedMedia } from "@/prisma/removed";
import { createList, createUser, getEpisode } from "@/prisma/user";
import Link from "next/link";
import MobileNav from "@/components/shared/MobileNav";
@@ -45,6 +45,19 @@ export async function getServerSideProps(context) {
const epiNumber = query?.num;
const dub = query?.dub;
+ const removed = await getRemovedMedia();
+
+ const isRemoved = removed?.find((i) => +i?.aniId === +aniId);
+
+ if (isRemoved) {
+ return {
+ redirect: {
+ destination: "/en/removed",
+ permanent: false,
+ },
+ };
+ }
+
const ress = await fetch(`https://graphql.anilist.co`, {
method: "POST",
headers: {
diff --git a/pages/en/removed.tsx b/pages/en/removed.tsx
new file mode 100644
index 0000000..8b8a704
--- /dev/null
+++ b/pages/en/removed.tsx
@@ -0,0 +1,50 @@
+import MobileNav from "@/components/shared/MobileNav";
+import { Navbar } from "@/components/shared/NavBar";
+import { useState } from "react";
+
+export default function RemovedPage() {
+ const [readMore, setReadMore] = useState(false);
+
+ return (
+ <>
+ <Navbar />
+ <MobileNav hideProfile />
+ <div className="flex flex-col items-center justify-center h-dvh font-karla">
+ <div className="flex-col flex-center container space-y-2">
+ <div className="size-24 lg:size-32 text-white">
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
+ <path
+ fill="currentColor"
+ d="m955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48M480 416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8zm32 352a48.01 48.01 0 0 1 0-96a48.01 48.01 0 0 1 0 96"
+ ></path>
+ </svg>
+ </div>
+ <div className="font-karla font-bold lg:text-3xl text-center">
+ This content has been removed from the site.
+ </div>
+ <p
+ className="hover:text-action text-zinc-500 cursor-pointer"
+ onClick={() => {
+ setReadMore((prev) => !prev);
+ }}
+ >
+ Why am I seeing this?
+ </p>
+ <p
+ className={`opacity-0 ${
+ readMore ? "opacity-100" : ""
+ } transition-all duration-200 p-2 bg-secondary rounded-md font-roboto text-sm lg:text-base text-zinc-300`}
+ >
+ Unfortunately, the media you were trying to access has been removed
+ from our site due to copyright infringement. We take intellectual
+ property rights seriously and strive to maintain a platform that
+ respects the creative works of others. If you have any questions or
+ concerns, please feel free to contact our support team for further
+ assistance. Thank you for your understanding and cooperation in
+ upholding a fair and lawful online environment.
+ </p>
+ </div>
+ </div>
+ </>
+ );
+}
diff --git a/prisma/removed.ts b/prisma/removed.ts
new file mode 100644
index 0000000..b6e31be
--- /dev/null
+++ b/prisma/removed.ts
@@ -0,0 +1,10 @@
+import { prisma } from "@/lib/prisma";
+
+export const getRemovedMedia = async (): Promise<any | null> => {
+ try {
+ const removedMedia = await prisma.removedMedia.findMany();
+ return removedMedia;
+ } catch (error) {
+ return null;
+ }
+};
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 040864e..d4b6607 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -7,6 +7,12 @@ generator client {
provider = "prisma-client-js"
}
+model RemovedMedia {
+ id String @id @default(cuid())
+ aniId String?
+ additions String[]
+}
+
model UserProfile {
id String @id @default(cuid())
name String @unique