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"
|
var downloadType = "attachment"
|
||||||
if (req.query.playInBrowser) downloadType = "inline";
|
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 = [
|
var baseArgs = [
|
||||||
// Remove ffmpeg's console spamming
|
// Remove ffmpeg's console spamming
|
||||||
'-loglevel', 'error',
|
'-loglevel', 'error',
|
||||||
|
@ -133,16 +134,33 @@ expressManager.app.get("/download", async (req, res) => {
|
||||||
|
|
||||||
ffmpegProcess.stdio[1].pipe(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])
|
Readable.fromWeb(audio.body).pipe(ffmpegProcess.stdio[4])
|
||||||
|
|
||||||
if (needsVideo) {
|
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])
|
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 {
|
} else {
|
||||||
res.send("Invalid URL!")
|
res.send("Invalid URL!")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue