From 151add9854a570dcc111df3a2c0f1400ca45220f Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 8 May 2025 07:14:21 -0400 Subject: [PATCH] Fix http api --- index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 3398c71..50daf87 100644 --- a/index.ts +++ b/index.ts @@ -24,12 +24,15 @@ Bun.serve({ const { manifestMimeType, manifest } = await utils.fetchTrack(trackId) - const audio = await utils.tagFlac(trackId, await utils.downloadFlac(manifestMimeType, manifest)) + const audio = await utils.downloadFlac(manifestMimeType, manifest); + if (audio.mimeType === "audio/flac") { + audio.buffer = Buffer.from(await utils.tagFlac(trackId, audio.buffer)) + } //await Bun.write(`downloaded/${trackId}.flac`, audio) - return new Response(audio, { + return new Response(audio.buffer, { headers: { - "Content-Type": "audio/flac", + "Content-Type": audio.mimeType, //"Content-Disposition": `attachment; filename="${trackId}.flac"`, "Cache-Control": "public, max-age=31536000", "ETag": trackId.toString(),