More compatiblity
This commit is contained in:
parent
83e901520c
commit
d8f867745d
1 changed files with 25 additions and 22 deletions
29
index.js
29
index.js
|
@ -37,10 +37,10 @@ app.get("/convert", async (req, res) => {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
ffmpegProcess.stderr.setEncoding('utf-8')
|
// ffmpegProcess.stderr.setEncoding('utf-8')
|
||||||
ffmpegProcess.stderr.on('data', (data) => {
|
// ffmpegProcess.stderr.on('data', (data) => {
|
||||||
console.log(data)
|
// console.log(data)
|
||||||
})
|
// })
|
||||||
// These are debugging lines to watch FFMPEG output :3
|
// These are debugging lines to watch FFMPEG output :3
|
||||||
|
|
||||||
ffmpegProcess.stdio[1].pipe(res)
|
ffmpegProcess.stdio[1].pipe(res)
|
||||||
|
@ -62,26 +62,30 @@ app.get("/download", async (req, res) => {
|
||||||
|
|
||||||
res.write(downloadHTML.substring(0, downloadHTML.indexOf("{CONTENT}")))
|
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)) {
|
if (!["mp3"].includes(format)) {
|
||||||
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + '.webm'
|
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + fileExtension
|
||||||
var filePath = path.join(__dirname, 'downloads', fileName)
|
var filePath = path.join(__dirname, 'downloads', fileName).trim()
|
||||||
var ytdlpProcess = cp.spawn('yt-dlp', [
|
var ytdlpProcess = cp.spawn('yt-dlp', [
|
||||||
url,
|
url,
|
||||||
'-o', filePath,
|
'-o', filePath.substring(0, filePath.lastIndexOf('.')),
|
||||||
'--max-filesize', MAX_FILESIZE + 'm',
|
'--max-filesize', MAX_FILESIZE + 'm',
|
||||||
'-S', 'res:' + quality
|
'-S', 'res:' + quality,
|
||||||
|
'--no-playlist',
|
||||||
])
|
])
|
||||||
} else {
|
} 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 filePath = path.join(__dirname, 'downloads', fileName)
|
||||||
var ytdlpProcess = cp.spawn('yt-dlp', [
|
var ytdlpProcess = cp.spawn('yt-dlp', [
|
||||||
url,
|
url,
|
||||||
'-x',
|
'-x',
|
||||||
'-o', filePath,
|
'-o', filePath.substring(0, filePath.lastIndexOf('.')),
|
||||||
'--max-filesize', MAX_FILESIZE + 'm',
|
'--max-filesize', MAX_FILESIZE + 'm',
|
||||||
|
'--no-playlist',
|
||||||
])
|
])
|
||||||
fileName += '.opus'
|
|
||||||
filePath = path.join(__dirname, 'downloads', fileName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastDownload = 0
|
var lastDownload = 0
|
||||||
|
@ -124,7 +128,6 @@ app.get("/download", async (req, res) => {
|
||||||
res.write(downloadHTML.substring(downloadHTML.indexOf("{CONTENT}") + 9), () => { res.end() })
|
res.write(downloadHTML.substring(downloadHTML.indexOf("{CONTENT}") + 9), () => { res.end() })
|
||||||
} else {
|
} 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>")
|
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)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue