api/processing: append audio extension to filename before response

This commit is contained in:
dumbmoron 2024-09-07 12:16:32 +00:00
parent c52aa76426
commit 438fce3c58
No known key found for this signature in database
2 changed files with 6 additions and 7 deletions

View file

@ -196,6 +196,10 @@ export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disab
break;
}
if (defaultParams.filename && (action === "picker" || action === "audio")) {
defaultParams.filename += `.${audioFormat}`;
}
if (alwaysProxy && responseType === "redirect") {
responseType = "tunnel";
params.type = "proxy";

View file

@ -47,13 +47,8 @@ const proxy = async (streamInfo, res) => {
);
try {
let filename = streamInfo.filename;
if (streamInfo.audioFormat) {
filename = `${streamInfo.filename}.${streamInfo.audioFormat}`
}
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');
res.setHeader('Content-disposition', contentDisposition(filename));
res.setHeader('Content-disposition', contentDisposition(streamInfo.filename));
const { body: stream, headers, statusCode } = await request(streamInfo.urls, {
headers: {
@ -255,7 +250,7 @@ const convertAudio = (streamInfo, res) => {
const [,,, muxOutput] = process.stdio;
res.setHeader('Connection', 'keep-alive');
res.setHeader('Content-Disposition', contentDisposition(`${streamInfo.filename}.${streamInfo.audioFormat}`));
res.setHeader('Content-Disposition', contentDisposition(streamInfo.filename));
pipe(muxOutput, res, shutdown);
res.on('finish', shutdown);