More compatiblity

This commit is contained in:
Bingus_Violet 2024-01-18 18:05:00 -06:00
parent 83e901520c
commit d8f867745d

View file

@ -37,10 +37,10 @@ app.get("/convert", async (req, res) => {
],
})
ffmpegProcess.stderr.setEncoding('utf-8')
ffmpegProcess.stderr.on('data', (data) => {
console.log(data)
})
// ffmpegProcess.stderr.setEncoding('utf-8')
// ffmpegProcess.stderr.on('data', (data) => {
// console.log(data)
// })
// These are debugging lines to watch FFMPEG output :3
ffmpegProcess.stdio[1].pipe(res)
@ -62,26 +62,30 @@ app.get("/download", async (req, res) => {
res.write(downloadHTML.substring(0, downloadHTML.indexOf("{CONTENT}")))
var fileExtension = cp.spawnSync('yt-dlp', ['--get-filename', url]).stdout.toString()
fileExtension = fileExtension.substring(fileExtension.lastIndexOf('.'))
if (!["mp3"].includes(format)) {
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + '.webm'
var filePath = path.join(__dirname, 'downloads', fileName)
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + fileExtension
var filePath = path.join(__dirname, 'downloads', fileName).trim()
var ytdlpProcess = cp.spawn('yt-dlp', [
url,
'-o', filePath,
'-o', filePath.substring(0, filePath.lastIndexOf('.')),
'--max-filesize', MAX_FILESIZE + 'm',
'-S', 'res:' + quality
'-S', 'res:' + quality,
'--no-playlist',
])
} else {
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString()
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + fileExtension
var filePath = path.join(__dirname, 'downloads', fileName)
var ytdlpProcess = cp.spawn('yt-dlp', [
url,
'-x',
'-o', filePath,
'-o', filePath.substring(0, filePath.lastIndexOf('.')),
'--max-filesize', MAX_FILESIZE + 'm',
'--no-playlist',
])
fileName += '.opus'
filePath = path.join(__dirname, 'downloads', fileName)
}
var lastDownload = 0
@ -124,7 +128,6 @@ app.get("/download", async (req, res) => {
res.write(downloadHTML.substring(downloadHTML.indexOf("{CONTENT}") + 9), () => { res.end() })
} else {
res.write("<p>An error has occured!!! We're not exactly sure what the error is, but we cant seem to find the download file. Double check the URL, and if the URL is fine, then file an issue on codeberg. </p>")
console.log(filePath)
}
})