mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-13 11:55:05 +01:00
Re-implement disallowed ids in v4
This commit is contained in:
parent
ad750ef3d9
commit
4a7c18e3e8
@ -13,11 +13,19 @@ import { Loading } from "@/components/layout/Loading";
|
|||||||
import { Paragraph } from "@/components/text/Paragraph";
|
import { Paragraph } from "@/components/text/Paragraph";
|
||||||
import { Title } from "@/components/text/Title";
|
import { Title } from "@/components/text/Title";
|
||||||
import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout";
|
import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout";
|
||||||
|
import { conf } from "@/setup/config";
|
||||||
|
|
||||||
export interface MetaPartProps {
|
export interface MetaPartProps {
|
||||||
onGetMeta?: (meta: DetailedMeta, episodeId?: string) => void;
|
onGetMeta?: (meta: DetailedMeta, episodeId?: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isDisallowedMedia(id: string, type: MWMediaType): boolean {
|
||||||
|
const disallowedEntries = conf().DISALLOWED_IDS.map((v) => v.split("-"));
|
||||||
|
if (disallowedEntries.find((entry) => id === entry[1] && type === entry[0]))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export function MetaPart(props: MetaPartProps) {
|
export function MetaPart(props: MetaPartProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const params = useParams<{
|
const params = useParams<{
|
||||||
@ -36,6 +44,8 @@ export function MetaPart(props: MetaPartProps) {
|
|||||||
}
|
}
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
|
|
||||||
|
if (isDisallowedMedia(data.id, data.type)) throw new Error("dmca");
|
||||||
|
|
||||||
let meta: AsyncReturnType<typeof getMetaFromId> = null;
|
let meta: AsyncReturnType<typeof getMetaFromId> = null;
|
||||||
try {
|
try {
|
||||||
meta = await getMetaFromId(data.type, data.id, params.season);
|
meta = await getMetaFromId(data.type, data.id, params.season);
|
||||||
@ -68,6 +78,29 @@ export function MetaPart(props: MetaPartProps) {
|
|||||||
props.onGetMeta?.(meta, epId);
|
props.onGetMeta?.(meta, epId);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
if (error && error.message === "dmca") {
|
||||||
|
return (
|
||||||
|
<ErrorLayout>
|
||||||
|
<ErrorContainer>
|
||||||
|
<IconPill icon={Icons.DRAGON}>Removed</IconPill>
|
||||||
|
<Title>Media has been removed</Title>
|
||||||
|
<Paragraph>
|
||||||
|
This media is no longer available due to a takedown notice or
|
||||||
|
copyright claim.
|
||||||
|
</Paragraph>
|
||||||
|
<Button
|
||||||
|
href="/"
|
||||||
|
theme="purple"
|
||||||
|
padding="md:px-12 p-2.5"
|
||||||
|
className="mt-6"
|
||||||
|
>
|
||||||
|
{t("player.metadata.failed.homeButton")}
|
||||||
|
</Button>
|
||||||
|
</ErrorContainer>
|
||||||
|
</ErrorLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
<ErrorLayout>
|
<ErrorLayout>
|
||||||
|
@ -67,6 +67,7 @@ export function conf(): RuntimeConfig {
|
|||||||
NORMAL_ROUTER: getKey("NORMAL_ROUTER", "false") === "true",
|
NORMAL_ROUTER: getKey("NORMAL_ROUTER", "false") === "true",
|
||||||
DISALLOWED_IDS: getKey("DISALLOWED_IDS", "")
|
DISALLOWED_IDS: getKey("DISALLOWED_IDS", "")
|
||||||
.split(",")
|
.split(",")
|
||||||
.map((v) => v.trim()), // Should be comma-seperated and contain the media type and ID, formatted like so: movie-753342,movie-753342,movie-753342
|
.map((v) => v.trim())
|
||||||
|
.filter((v) => v.length > 0), // Should be comma-seperated and contain the media type and ID, formatted like so: movie-753342,movie-753342,movie-753342
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user