Show video posters in the library by building a first-frame thumb when one is missing.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-02 20:53:53 -05:00
co-authored by Cursor
parent 81fb5051a3
commit 71e2e4b326
5 changed files with 39 additions and 32 deletions
+5 -4
View File
@@ -1,13 +1,14 @@
import { existsSync, createReadStream } from 'node:fs'
import { clipThumbPath, fileEtag, sniffImageType } from '~/server/utils/library'
import { clipThumbPath, ensureClipThumb, fileEtag, sniffImageType } from '~/server/utils/library'
export default defineEventHandler((event) => {
export default defineEventHandler(async (event) => {
const { owner } = assertLibraryOwner(event)
const id = String(getRouterParam(event, 'id') || '')
const clip = getClip(owner, id)
assertFolderAccess(event, clip.folderId)
const path = clipThumbPath(owner, clip.id)
if (!existsSync(path)) {
let path = clipThumbPath(owner, clip.id)
if (!existsSync(path)) path = await ensureClipThumb(owner, clip.id)
if (!path || !existsSync(path)) {
throw createError({ statusCode: 404, statusMessage: 'Thumbnail not found' })
}
const etag = fileEtag(path)
+5 -7
View File
@@ -1,12 +1,10 @@
export default defineEventHandler((event) => {
const light = String(getQuery(event).light || '') === '1'
const library = publicLibrary(event, { light })
if (!light) {
try {
const { owner } = assertLibraryOwner(event)
const folderId = library.folders.find(folder => folder.unlocked)?.id
void maintainLibrary(owner, folderId).catch(() => null)
} catch { /* locked or anonymous — still return what we can */ }
}
try {
const { owner } = assertLibraryOwner(event)
const folderId = library.folders.find(folder => folder.unlocked)?.id
void maintainLibrary(owner, folderId).catch(() => null)
} catch { /* locked or anonymous — still return what we can */ }
return library
})