Add a persistent clip library with folders, optional password, and hidden-thumbnail glow.
Generated videos save into a chosen folder, sensitive clips skip thumbnails until played, and Docker writes the catalog to a Coolify volume. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
assertLibraryAccess(event)
|
||||
const id = getRouterParam(event, 'id')
|
||||
await deleteClip(String(id))
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,19 @@
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
assertLibraryAccess(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
const clip = getClip(id)
|
||||
if (clip.hideThumbnail) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'Thumbnail hidden' })
|
||||
}
|
||||
const path = clipThumbPath(clip.id)
|
||||
if (!existsSync(path)) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'Thumbnail not found' })
|
||||
}
|
||||
const buf = readFileSync(path)
|
||||
const png = buf[0] === 0x89 && buf[1] === 0x50
|
||||
setHeader(event, 'Content-Type', png ? 'image/png' : 'image/jpeg')
|
||||
setHeader(event, 'Cache-Control', 'private, max-age=3600')
|
||||
return buf
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
assertLibraryAccess(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
const clip = getClip(id)
|
||||
const path = clipVideoPath(clip.id)
|
||||
if (!existsSync(path)) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'Video file is missing' })
|
||||
}
|
||||
setHeader(event, 'Content-Type', 'video/mp4')
|
||||
setHeader(event, 'Content-Disposition', `inline; filename="${clip.id}.mp4"`)
|
||||
setHeader(event, 'Cache-Control', 'private, max-age=3600')
|
||||
return readFileSync(path)
|
||||
})
|
||||
Reference in New Issue
Block a user