From a949591f9987a29dd48fcd1e9a8022ca4ae5b94c Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Wed, 6 Nov 2024 18:51:46 -0600 Subject: [PATCH] New option to play videos in browser --- downloader.js | 5 ++++- static/index.html | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/downloader.js b/downloader.js index 70a3f04..a1550ba 100644 --- a/downloader.js +++ b/downloader.js @@ -31,7 +31,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 diff --git a/static/index.html b/static/index.html index ef5c825..f4a21e3 100644 --- a/static/index.html +++ b/static/index.html @@ -61,6 +61,10 @@ +
+ +

Play in browser

+