Should work with all sites now. tiktok mp3s dont work for some reason.
This commit is contained in:
parent
7df6225669
commit
c211cfcc0b
1 changed files with 80 additions and 62 deletions
|
@ -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!")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue