From 438fce3c58d7f6dce6f69714172942b18e89b761 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Sat, 7 Sep 2024 12:16:32 +0000 Subject: [PATCH] api/processing: append audio extension to filename before response --- api/src/processing/match-action.js | 4 ++++ api/src/stream/types.js | 9 ++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/api/src/processing/match-action.js b/api/src/processing/match-action.js index b8e39355..2e7b7f1b 100644 --- a/api/src/processing/match-action.js +++ b/api/src/processing/match-action.js @@ -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"; diff --git a/api/src/stream/types.js b/api/src/stream/types.js index 1076468d..ed949e5e 100644 --- a/api/src/stream/types.js +++ b/api/src/stream/types.js @@ -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);