Optimize audio formats
This commit is contained in:
parent
7395a1f60f
commit
7ecff6e95d
1 changed files with 21 additions and 7 deletions
28
index.js
28
index.js
|
@ -58,14 +58,28 @@ app.get("/download", async (req, res) => {
|
|||
|
||||
res.write(downloadHTML.substring(0, downloadHTML.indexOf("{CONTENT}")))
|
||||
|
||||
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + '.' + 'webm'
|
||||
var filePath = path.join(__dirname, 'downloads', fileName)
|
||||
|
||||
var ytdlpProcess = cp.spawn('yt-dlp', [
|
||||
url,
|
||||
'-o', filePath,
|
||||
'--max-filesize', MAX_FILESIZE + 'm'
|
||||
])
|
||||
if (!format in ["mp3"]) {
|
||||
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + '.webm'
|
||||
var filePath = path.join(__dirname, 'downloads', fileName)
|
||||
var ytdlpProcess = cp.spawn('yt-dlp', [
|
||||
url,
|
||||
'-o', filePath,
|
||||
'--max-filesize', MAX_FILESIZE + 'm'
|
||||
])
|
||||
} else {
|
||||
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString()
|
||||
var filePath = path.join(__dirname, 'downloads', fileName)
|
||||
var ytdlpProcess = cp.spawn('yt-dlp', [
|
||||
url,
|
||||
'-x',
|
||||
'-o', filePath,
|
||||
'--max-filesize', MAX_FILESIZE + 'm',
|
||||
|
||||
])
|
||||
fileName += '.opus'
|
||||
filePath = path.join(__dirname, 'downloads', fileName)
|
||||
}
|
||||
|
||||
var lastDownload = 0
|
||||
|
||||
|
|
Loading…
Reference in a new issue