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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user