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