This commit is contained in:
bingus_violet 2024-11-06 19:35:42 -06:00
parent 4f88beab0a
commit 716777f1f5

View file

@ -38,7 +38,7 @@ expressManager.app.get("/download", async (req, res) => {
format = req.query.format, format = req.query.format,
trimAudio = req.query.trimAudio && audioFormats.includes(format) || false 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("?")) var metadata = req.url.substring(req.url.indexOf("?"))
res.redirect("/watch" + metadata) res.redirect("/watch" + metadata)
} else if (ytdl.validateURL(url) && qualityLabels.includes(quality)) { } 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) 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) => { var audioFormat = ytdl.chooseFormat(info.formats, { filter: (format) => {
return format.hasAudio && !format.hasVideo return format.hasAudio && !format.hasVideo