From bd7b0d65f3d486249ff116bed2d70c972f33cb2a Mon Sep 17 00:00:00 2001 From: Sneed Group Holder Date: Mon, 28 Oct 2024 11:50:23 -0500 Subject: [PATCH] fix final --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 930131c..ed9c038 100644 --- a/index.js +++ b/index.js @@ -62,7 +62,7 @@ app.get('/download', (req, res) => { } // Set the output file path - var outputPath = path.join('/tmp/downloads', `${getRandomHex()}.mp4`); + var outputPath = path.join('/tmp/downloads', `${getRandomHex()}`); // Create /tmp/downloads directory if it doesn't exist try { @@ -81,17 +81,18 @@ app.get('/download', (req, res) => { console.log('yt-dlp output:', stdout); - const downloadedFilePath = outputPath; + const downloadedFilePath = `${outputPath}.webm`; console.log('Downloaded file path:', downloadedFilePath); if (!downloadedFilePath || !fs.existsSync(downloadedFilePath)) { + console.log(`${downloadedFilePath}`) console.error('Error: Downloaded file not found or invalid path.'); return res.status(500).json({ error: 'Downloaded file not found or invalid path.' }); } // Send the file - res.download(downloadedFilePath, (err) => { + res.sendFile(downloadedFilePath, (err) => { if (err) { console.error('Error sending the file:', err); return res.status(500).json({ error: 'Failed to send the file.', details: err.message });