Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 2,594 Bytes
8f2b05f |
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 |
import { AppQueryProps } from "@/types"
import { Main } from "../main"
import { getVideos } from "../server/actions/ai-tube-hf/getVideos"
import { getVideo } from "../server/actions/ai-tube-hf/getVideo"
import { Metadata } from "next"
// https://nextjs.org/docs/pages/building-your-application/optimizing/fonts
export async function generateMetadata(
{ params, searchParams: { m: mediaId } }: AppQueryProps,
// parent: ResolvingMetadata
): Promise<Metadata> {
// read route params
const metadataBase = new URL('https://huggingface.co./spaces/jbilcke-hf/ai-tube')
try {
const publicTrack = await getVideo({ videoId: mediaId, neverThrow: true })
if (!publicTrack) {
throw new Error("Video not found")
}
const openGraph = {
// 'music.song' | 'music.album' | 'music.playlist' | 'music.radio_station'
// | 'profile' | 'website' | 'video.tv_show' | 'video.other' | 'video.movie' | 'video.episode';
type: "music.song",
duration: publicTrack.duration,
// albums?: null | string | URL | OGAlbum | Array<string | URL | OGAlbum>;
musicians: [publicTrack.channel.label, "AI (MusicGen)"],
// url: "https://example.com",
title: `${publicTrack.channel.label} - ${publicTrack.label}` || "", // put the video title here
description: publicTrack.description || "", // put the vide description here
siteName: "AiTube Music",
images: [
`https://huggingface.co./datasets/jbilcke-hf/ai-tube-index/resolve/main/videos/${publicTrack.id}.webp`
],
audio: [
{
"url": publicTrack.assetUrl
}
]
}
return {
title: `${publicTrack.label} - AiTube Music`,
metadataBase,
openGraph,
}
} catch (err) {
return {
title: "AiTube Music",
metadataBase,
openGraph: {
type: "website",
// url: "https://example.com",
title: "AiTube Music", // put the video title here
description: "", // put the vide description here
siteName: "AiTube Music",
videos: [],
images: [],
},
}
}
}
export default async function MusicPage({ searchParams: { m: mediaId } }: AppQueryProps) {
const publicTracks = await getVideos({
sortBy: "date",
mandatoryTags: ["music"],
maxVideos: 25,
neverThrow: true,
})
// at some point we will probably migrate to a getMedia({ mediaId }) instead
const publicTrack = await getVideo({
videoId: mediaId,
neverThrow: true
})
return (<Main publicTracks={publicTracks} publicTrack={publicTrack} />)
} |