Spaces:
Running
Running
File size: 2,616 Bytes
761239a df83860 1185ec1 df83860 3d4392e df83860 9cea1bb df83860 ac7030c df83860 ac7030c df83860 ac7030c 761239a df83860 8f2b05f df83860 ac7030c 8f2b05f dfb38a6 ac7030c dfb38a6 df83860 ac7030c df83860 e40bd21 ac7030c e40bd21 ac7030c e40bd21 df83860 8f2b05f df83860 8f2b05f df83860 8f2b05f df83860 ac7030c 3d4392e 9cea1bb df83860 3d4392e df83860 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
import { Metadata, ResolvingMetadata } from "next"
import { AppQueryProps } from "@/types/general"
import { Main } from "../main"
import { getVideo } from "../api/actions/ai-tube-hf/getVideo"
// https://nextjs.org/docs/pages/building-your-application/optimizing/fonts
export async function generateMetadata(
{ params, searchParams: { v: videoId } }: AppQueryProps,
parent: ResolvingMetadata
): Promise<Metadata> {
// read route params
const metadataBase = new URL('https://huggingface.co/spaces/jbilcke-hf/ai-tube')
try {
const media = await getVideo({ videoId, neverThrow: true })
if (!media) {
throw new Error("Video not found")
}
return {
title: `${media.label} - AiTube`,
metadataBase,
openGraph: {
// some cool stuff we could use here:
// 'video.tv_show' | 'video.other' | 'video.movie' | 'video.episode';
type: "video.other",
// url: "https://example.com",
title: media.label || "", // put the video title here
description: media.description || "", // put the video description here
siteName: "AiTube",
images: [
`https://huggingface.co/datasets/jbilcke-hf/ai-tube-index/resolve/main/videos/${media.id}.webp`
],
videos: [
{
"url": media.assetUrlHd || media.assetUrl
}
],
// images: ['/some-specific-page-image.jpg', ...previousImages],
},
twitter: {
card: "player",
site: "@flngr",
description: media.description || "",
images: `https://huggingface.co/datasets/jbilcke-hf/ai-tube-index/resolve/main/videos/${media.id}.webp`,
players: {
playerUrl: `${process.env.NEXT_PUBLIC_DOMAIN}/embed?v=${media.id}`,
streamUrl: `https://huggingface.co/datasets/jbilcke-hf/ai-tube-index/resolve/main/videos/${media.id}.mp4`,
width: 1024,
height: 576
}
}
}
} catch (err) {
return {
title: "AiTube",
metadataBase,
openGraph: {
type: "website",
// url: "https://example.com",
title: "AiTube", // put the video title here
description: "", // put the vide description here
siteName: "AiTube",
videos: [],
images: [],
},
}
}
}
export default async function WatchPage({ searchParams: {
v: videoId,
// TODO add:
// m: mediaId
} }: AppQueryProps) {
const publicMedia = await getVideo({ videoId, neverThrow: true })
// console.log("WatchPage: --> " + video?.id)
return (
<Main publicMedia={publicMedia} />
)
} |