--- import Layout from "@layouts/Layout.astro"; import TitleBar from "@components/TitleBar.astro"; import { format } from "date-fns"; import { zhCN } from "date-fns/locale"; import MetadataRow from "@components/InfoPage/MetadataRow.astro"; import { getAllSnapshots } from "src/db/snapshots/getAllSnapshots"; import { getAidFromBV } from "src/db/bilibili_metadata/getAidFromBV"; import { getVideoMetadata } from "src/db/bilibili_metadata/getVideoMetadata"; import { aidExists as idExists } from "src/db/bilibili_metadata/aidExists"; const { id } = Astro.params; async function getVideoAid(id: string) { if (id.startsWith("av")) { return parseInt(id.slice(2)); } else if (id.startsWith("BV")) { return getAidFromBV(id); } return parseInt(id); } if (!id) { Astro.response.status = 404; return new Response(null, { status: 404 }); } const aid = await getVideoAid(id); if (!aid || isNaN(aid)) { Astro.response.status = 404; return new Response(null, { status: 404 }); } const aidExists = await idExists(aid); if (!aidExists) { Astro.response.status = 404; return new Response(null, { status: 404 }); } const videoInfo = await getVideoMetadata(aid); const snapshots = await getAllSnapshots(aid); ---

视频信息: av{aid}

基本信息

播放量历史数据

{ snapshots && snapshots.length > 0 ? (
{snapshots.map((snapshot) => ( ))}
创建时间 观看 硬币 点赞 收藏 分享 弹幕 评论
{format(new Date(snapshot.created_at), "yyyy-MM-dd HH:mm:ss", { locale: zhCN, })} {snapshot.views} {snapshot.coins} {snapshot.likes} {snapshot.favorites} {snapshot.shares} {snapshot.danmakus} {snapshot.replies}
) : (

暂无历史数据。

) }