diff options
| author | Thomas Grothe <grothe.tr@gmail.com> | 2026-03-07 23:32:05 -0500 |
|---|---|---|
| committer | Thomas Grothe <grothe.tr@gmail.com> | 2026-03-07 23:32:05 -0500 |
| commit | dbd1386a43ae9e7013809be2e0bd0e1c049059fc (patch) | |
| tree | 22588cb21dfa1cc941e13031e73cb85cdfb7f402 /src/routes/api/video | |
Diffstat (limited to 'src/routes/api/video')
| -rw-r--r-- | src/routes/api/video/[id]/+server.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/routes/api/video/[id]/+server.ts b/src/routes/api/video/[id]/+server.ts new file mode 100644 index 0000000..9a64c36 --- /dev/null +++ b/src/routes/api/video/[id]/+server.ts @@ -0,0 +1,18 @@ +import { json } from '@sveltejs/kit'; +import { getVideo } from '$lib/server/ytdlp'; +import type { RequestHandler } from './$types'; + +export const GET: RequestHandler = async ({ params }) => { + const { id } = params; + if (!id) { + return json({ error: 'Missing video ID' }, { status: 400 }); + } + + try { + const video = await getVideo(id); + return json(video); + } catch (e) { + console.error('Video fetch error:', e); + return json({ error: 'Failed to fetch video' }, { status: 500 }); + } +}; |
