lil fixee
This commit is contained in:
parent
1b65b47408
commit
38a1cedba5
1 changed files with 6 additions and 5 deletions
11
index.js
11
index.js
|
@ -20,6 +20,7 @@ app.get("/convert", async (req, res) => {
|
||||||
|
|
||||||
var filePath = path.join(__dirname, 'downloads', file)
|
var filePath = path.join(__dirname, 'downloads', file)
|
||||||
|
|
||||||
|
console.log(filePath)
|
||||||
if (fs.existsSync(filePath)) {
|
if (fs.existsSync(filePath)) {
|
||||||
var ytdlpProcess = cp.spawnSync('yt-dlp', ['--get-filename', url])
|
var ytdlpProcess = cp.spawnSync('yt-dlp', ['--get-filename', url])
|
||||||
var name = ytdlpProcess.stdout.toString()
|
var name = ytdlpProcess.stdout.toString()
|
||||||
|
@ -62,11 +63,9 @@ app.get("/download", async (req, res) => {
|
||||||
|
|
||||||
res.write(downloadHTML.substring(0, downloadHTML.indexOf("{CONTENT}")))
|
res.write(downloadHTML.substring(0, downloadHTML.indexOf("{CONTENT}")))
|
||||||
|
|
||||||
if (!["mp3"].includes(format)) {
|
var fileName = cp.spawnSync('yt-dlp', ['-S', 'res:' + quality,'--get-filename', url]).stdout.toString()
|
||||||
var fileExtension = cp.spawnSync('yt-dlp', ['-S', 'res:' + quality,'--get-filename', url]).stdout.toString()
|
|
||||||
fileExtension = fileExtension.substring(fileExtension.lastIndexOf('.'))
|
|
||||||
|
|
||||||
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 filePath = path.join(__dirname, 'downloads', fileName).trim()
|
||||||
var ytdlpProcess = cp.spawn('yt-dlp', [
|
var ytdlpProcess = cp.spawn('yt-dlp', [
|
||||||
url,
|
url,
|
||||||
|
@ -76,14 +75,16 @@ app.get("/download", async (req, res) => {
|
||||||
'--no-playlist',
|
'--no-playlist',
|
||||||
])
|
])
|
||||||
} else {
|
} 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 filePath = path.join(__dirname, 'downloads', fileName).trim()
|
||||||
|
|
||||||
var ytdlpProcess = cp.spawn('yt-dlp', [
|
var ytdlpProcess = cp.spawn('yt-dlp', [
|
||||||
url,
|
url,
|
||||||
'-x',
|
'-x',
|
||||||
'-o', filePath.substring(0, filePath.lastIndexOf('.')),
|
'-o', filePath.substring(0, filePath.lastIndexOf('.')),
|
||||||
'--max-filesize', MAX_FILESIZE + 'm',
|
'--max-filesize', MAX_FILESIZE + 'm',
|
||||||
'--no-playlist',
|
'--no-playlist',
|
||||||
|
'--audio-format', 'mp3',
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue