Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
Add getRemovedMedia function and handle redirect for removed media
Browse files Browse the repository at this point in the history
  • Loading branch information
DevanAbinaya committed Jan 11, 2024
1 parent da6555a commit e9aea5f
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ docker-compose.yml
/backup
release-template.md
.vscode
pnpm-lock.yaml

# debug
npm-debug.log*
Expand Down
15 changes: 14 additions & 1 deletion pages/en/anime/watch/[...info].js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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: {
Expand Down
50 changes: 50 additions & 0 deletions pages/en/removed.tsx
Original file line number Diff line number Diff line change
@@ -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>
</>
);
}
10 changes: 10 additions & 0 deletions prisma/removed.ts
Original file line number Diff line number Diff line change
@@ -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;
}
};
6 changes: 6 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e9aea5f

Please sign in to comment.