Should work with all sites now. tiktok mp3s dont work for some reason.

This commit is contained in:
bingus_violet 2025-07-27 21:12:27 -05:00
parent 7df6225669
commit c211cfcc0b

View file

@ -75,14 +75,15 @@ expressManager.app.get("/download", async (req, res) => {
}
})
console.log(info)
var filename = info.data.filename || info.data.output.filename
res.setHeader("Content-Disposition", `${downloadType}; filename="${filename.replace(/[^a-z0-9 ]/gi, '')}.${format}"`)
if (info.data.service == "youtube") {
var downloadType = "attachment"
if (req.query.playInBrowser) downloadType = "inline";
var filename = info.data.filename || info.data.output.filename
res.setHeader("Content-Disposition", `${downloadType}; filename="${filename.replace(/[^a-z0-9 ]/gi, '')}.${format}"`)
var baseArgs = [
// Remove ffmpeg's console spamming
'-loglevel', 'error',
@ -133,16 +134,33 @@ expressManager.app.get("/download", async (req, res) => {
ffmpegProcess.stdio[1].pipe(res)
var audio = await fetch(info.data.url || info.data.tunnel[1] || info.data.tunnel[0])
var audio = await fetch(info.data.tunnel[1] || info.data.tunnel[0])
Readable.fromWeb(audio.body).pipe(ffmpegProcess.stdio[4])
if (needsVideo) {
var video = await fetch(info.data.url || info.data.tunnel[0])
var video = await fetch(info.data.tunnel[0])
Readable.fromWeb(video.body).pipe(ffmpegProcess.stdio[5])
}
} else {
var info = await axios.post("https://cobalt.univerter.dev/", {
url,
downloadMode,
videoQuality: quality,
localProcessing: false,
}, {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
console.log(info)
var video = await fetch(info.data.url)
Readable.fromWeb(video.body).pipe(res)
}
} else {
res.send("Invalid URL!")
}