lil fixee

This commit is contained in:
Bingus_Violet 2024-01-19 18:30:25 -06:00
parent 1b65b47408
commit 38a1cedba5

View file

@ -20,6 +20,7 @@ app.get("/convert", async (req, res) => {
var filePath = path.join(__dirname, 'downloads', file)
console.log(filePath)
if (fs.existsSync(filePath)) {
var ytdlpProcess = cp.spawnSync('yt-dlp', ['--get-filename', url])
var name = ytdlpProcess.stdout.toString()
@ -62,11 +63,9 @@ app.get("/download", async (req, res) => {
res.write(downloadHTML.substring(0, downloadHTML.indexOf("{CONTENT}")))
if (!["mp3"].includes(format)) {
var fileExtension = cp.spawnSync('yt-dlp', ['-S', 'res:' + quality,'--get-filename', url]).stdout.toString()
fileExtension = fileExtension.substring(fileExtension.lastIndexOf('.'))
var fileName = cp.spawnSync('yt-dlp', ['-S', 'res:' + quality,'--get-filename', url]).stdout.toString()
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + fileExtension
if (!["mp3", "wav", "ogx"].includes(format)) {
var filePath = path.join(__dirname, 'downloads', fileName).trim()
var ytdlpProcess = cp.spawn('yt-dlp', [
url,
@ -76,14 +75,16 @@ app.get("/download", async (req, res) => {
'--no-playlist',
])
} else {
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + '.opus'
fileName = fileName.substring(0, fileName.lastIndexOf(".")) + '.mp3'
var filePath = path.join(__dirname, 'downloads', fileName).trim()
var ytdlpProcess = cp.spawn('yt-dlp', [
url,
'-x',
'-o', filePath.substring(0, filePath.lastIndexOf('.')),
'--max-filesize', MAX_FILESIZE + 'm',
'--no-playlist',
'--audio-format', 'mp3',
])
}