|
|
|
@ -13,11 +13,19 @@ import { Loading } from "@/components/layout/Loading";
@@ -13,11 +13,19 @@ import { Loading } from "@/components/layout/Loading";
|
|
|
|
|
import { Paragraph } from "@/components/text/Paragraph"; |
|
|
|
|
import { Title } from "@/components/text/Title"; |
|
|
|
|
import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout"; |
|
|
|
|
import { conf } from "@/setup/config"; |
|
|
|
|
|
|
|
|
|
export interface MetaPartProps { |
|
|
|
|
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) { |
|
|
|
|
const { t } = useTranslation(); |
|
|
|
|
const params = useParams<{ |
|
|
|
@ -36,6 +44,8 @@ export function MetaPart(props: MetaPartProps) {
@@ -36,6 +44,8 @@ export function MetaPart(props: MetaPartProps) {
|
|
|
|
|
} |
|
|
|
|
if (!data) return null; |
|
|
|
|
|
|
|
|
|
if (isDisallowedMedia(data.id, data.type)) throw new Error("dmca"); |
|
|
|
|
|
|
|
|
|
let meta: AsyncReturnType<typeof getMetaFromId> = null; |
|
|
|
|
try { |
|
|
|
|
meta = await getMetaFromId(data.type, data.id, params.season); |
|
|
|
@ -68,6 +78,29 @@ export function MetaPart(props: MetaPartProps) {
@@ -68,6 +78,29 @@ export function MetaPart(props: MetaPartProps) {
|
|
|
|
|
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) { |
|
|
|
|
return ( |
|
|
|
|
<ErrorLayout> |
|
|
|
|