processing server update

This commit is contained in:
sky
2025-08-12 15:39:52 -04:00
parent fa82d30549
commit de79c682c8

View File

@ -5,10 +5,10 @@ Bun.serve({
routes: { routes: {
"/status": new Response("OK"), "/status": new Response("OK"),
"/process": { "/process": {
POST: async req => { GET: async req => {
if(req.headers.get("X-Authentication") == process.env.PRIVATE_KEY) { if(req.headers.get("X-Authentication") == process.env.PRIVATE_KEY) {
let path = "tmp/" + Bun.randomUUIDv7(); let path = "tmp/" + Bun.randomUUIDv7();
await Bun.write(path + ".mp4", await req.body.blob()); await `yt-dlp '${req.query.url}' -q -o "${path.mp4}"`
await $`ffmpeg -i ${path}.mp4 -map_metadata -1 -map 0 -map -0:v -b:a 64k ${path}.ogg` await $`ffmpeg -i ${path}.mp4 -map_metadata -1 -map 0 -map -0:v -b:a 64k ${path}.ogg`
await (Bun.file(path + ".mp4")).delete(); await (Bun.file(path + ".mp4")).delete();
let response = new Response(await Bun.file(path + ".ogg").bytes(), { let response = new Response(await Bun.file(path + ".ogg").bytes(), {