Temporary fix for audio files
This commit is contained in:
parent
598de0c426
commit
9f69e39b36
1 changed files with 5 additions and 5 deletions
10
index.js
10
index.js
|
@ -62,10 +62,10 @@ 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 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
|
||||
var filePath = path.join(__dirname, 'downloads', fileName).trim()
|
||||
var ytdlpProcess = cp.spawn('yt-dlp', [
|
||||
|
@ -76,8 +76,7 @@ app.get("/download", async (req, res) => {
|
|||
'--no-playlist',
|
||||
])
|
||||
} else {
|
||||
|
||||
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + fileExtension
|
||||
var fileName = Math.round(Math.random() * 100_000_000_000_000).toString() + '.opus'
|
||||
var filePath = path.join(__dirname, 'downloads', fileName).trim()
|
||||
var ytdlpProcess = cp.spawn('yt-dlp', [
|
||||
url,
|
||||
|
@ -118,6 +117,7 @@ app.get("/download", async (req, res) => {
|
|||
var exited = false
|
||||
|
||||
ytdlpProcess.on('close', () => {
|
||||
console.log(filePath)
|
||||
if (exited) {
|
||||
if (fs.existsSync(filePath)) {
|
||||
fs.rmSync(filePath)
|
||||
|
|
Loading…
Reference in a new issue