Comment out file existence check and response headers for track API
This commit is contained in:
parent
5124e38399
commit
df0627dea2
1 changed files with 5 additions and 5 deletions
10
index.ts
10
index.ts
|
@ -9,7 +9,7 @@ Bun.serve({
|
||||||
"/api/track/:id": async req => {
|
"/api/track/:id": async req => {
|
||||||
const trackId = parseInt(req.params.id)
|
const trackId = parseInt(req.params.id)
|
||||||
|
|
||||||
const file = Bun.file(`downloaded/${trackId}.flac`)
|
/*const file = Bun.file(`downloaded/${trackId}.flac`)
|
||||||
|
|
||||||
if (await file.exists()) {
|
if (await file.exists()) {
|
||||||
return new Response(await file.arrayBuffer(), {
|
return new Response(await file.arrayBuffer(), {
|
||||||
|
@ -20,23 +20,23 @@ Bun.serve({
|
||||||
"ETag": trackId.toString(),
|
"ETag": trackId.toString(),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}*/
|
||||||
|
|
||||||
const { manifestMimeType, manifest } = await utils.fetchTrack(trackId)
|
const { manifestMimeType, manifest } = await utils.fetchTrack(trackId)
|
||||||
|
|
||||||
const audio = await utils.tagFlac(trackId, await utils.downloadFlac(manifestMimeType, manifest))
|
const audio = await utils.tagFlac(trackId, await utils.downloadFlac(manifestMimeType, manifest))
|
||||||
|
//await Bun.write(`downloaded/${trackId}.flac`, audio)
|
||||||
await Bun.write(`downloaded/${trackId}.flac`, audio)
|
|
||||||
|
|
||||||
return new Response(audio, {
|
return new Response(audio, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "audio/flac",
|
"Content-Type": "audio/flac",
|
||||||
"Content-Disposition": `attachment; filename="${trackId}.flac"`,
|
//"Content-Disposition": `attachment; filename="${trackId}.flac"`,
|
||||||
"Cache-Control": "public, max-age=31536000",
|
"Cache-Control": "public, max-age=31536000",
|
||||||
"ETag": trackId.toString(),
|
"ETag": trackId.toString(),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
"/api/@me/tracks": async () => {
|
"/api/@me/tracks": async () => {
|
||||||
const tracks = await utils.fetchTracks();
|
const tracks = await utils.fetchTracks();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue