From 716777f1f5fd887d813a4638d33cf2928abe94e3 Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Wed, 6 Nov 2024 19:35:42 -0600 Subject: [PATCH] fix mp3s --- downloader.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/downloader.js b/downloader.js index c8ccbd3..e00c88f 100644 --- a/downloader.js +++ b/downloader.js @@ -38,7 +38,7 @@ expressManager.app.get("/download", async (req, res) => { format = req.query.format, trimAudio = req.query.trimAudio && audioFormats.includes(format) || false - if (req.query.playInBrowser) { + if (req.query.playInBrowser && !audioFormats.includes(format)) { var metadata = req.url.substring(req.url.indexOf("?")) res.redirect("/watch" + metadata) } else if (ytdl.validateURL(url) && qualityLabels.includes(quality)) { @@ -46,7 +46,10 @@ expressManager.app.get("/download", async (req, res) => { var info = await ytdl.getInfo(url) - res.setHeader("Content-Disposition", `attachment; filename="${info.videoDetails.title.replace(/[^a-z0-9 ]/gi, '')}.${format}"`) + var downloadType = "attachment" + if (req.query.playInBrowser) downloadType = "inline"; + + res.setHeader("Content-Disposition", `${downloadType}; filename="${info.videoDetails.title.replace(/[^a-z0-9 ]/gi, '')}.${format}"`) var audioFormat = ytdl.chooseFormat(info.formats, { filter: (format) => { return format.hasAudio && !format.hasVideo