From e5e26222cee551198830ce8503eb6580d4ec2d29 Mon Sep 17 00:00:00 2001 From: bytedream Date: Sat, 31 Oct 2026 04:44:11 +0100 Subject: [PATCH] do not use video in opengraph --- src/pages/video/[name].astro | 15 +++------------ src/util/video.ts | 24 ++++-------------------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/pages/video/[name].astro b/src/pages/video/[name].astro index b511ab5..a8a39d3 100644 --- a/src/pages/video/[name].astro +++ b/src/pages/video/[name].astro @@ -12,26 +12,17 @@ if (!video) return new Response(null, { status: 404 }); const metadata = await getVideoMetadata(video); if (!metadata) return new Response(null, { status: 404 }); -const { title, description, width, height, duration } = metadata; +const { title, description } = metadata; const streamUrl = siteUrl(`video/${encodeURIComponent(video.name)}/stream`); const thumbnailUrl = siteUrl(`video/${encodeURIComponent(video.name)}/thumbnail.jpg`); -const thumbnailWidth = 1280; -const thumbnailHeight = width && Math.round((height / width) * thumbnailWidth); --- - + - - - - {streamUrl.startsWith('https') && } - - {width && } - {height && } - {duration && } +
diff --git a/src/util/video.ts b/src/util/video.ts index 8d12876..37d4a87 100644 --- a/src/util/video.ts +++ b/src/util/video.ts @@ -35,22 +35,16 @@ export interface VideoThumbnail { export interface VideoMetadata { title: string; description: string | null; - width: number; - height: number; - duration: number; } interface FFprobeStream { codec_type?: string; - width?: number; - height?: number; tags?: Record; } interface FFprobeResult { streams?: FFprobeStream[]; format?: { - duration?: string; tags?: Record; }; } @@ -113,9 +107,8 @@ export async function getVideoMetadata(video: ResolvedVideo): Promise stream.codec_type === 'video'); - if (!videoStream) throw new Error('no video stream'); - else if (!videoStream.width || !videoStream.height) throw new Error('invalid video stream height'); - - const tags = { ...videoStream.tags, ...parsed.format.tags }; - const duration = Number(parsed.format.duration); + const tags = { ...videoStream?.tags, ...parsed.format?.tags }; metadata = { title: tags['title'] || video.name, - description: (tags['synopsis'] || tags['longdescription'] || tags['description']) ?? null, - width: videoStream.width, - height: videoStream.height, - duration: Math.round(duration) + description: (tags['synopsis'] || tags['longdescription'] || tags['description']) ?? null }; } catch (e) { logger.warn({ error: e instanceof Error ? e.message : String(e) }, 'error while reading video metadata');