New option to play videos in browser

This commit is contained in:
bingus_violet 2024-11-06 18:51:46 -06:00
parent a688a6293f
commit a949591f99
2 changed files with 8 additions and 1 deletions

View file

@ -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