diff --git a/index.js b/index.js index b1a7e8a..305e81a 100644 --- a/index.js +++ b/index.js @@ -64,12 +64,15 @@ app.get('/download', (req, res) => { return res.status(500).json({ error: 'An error occurred while downloading the video.', details: stderr }); } + // Parse the output to get the file name + const filename = stdout.split('\n').find(line => line.includes('Destination'))?.split(' ')[1]; + if (!filename) { return res.status(500).json({ error: 'Downloaded file not found.' }); } // Full path of the downloaded file - const downloadedFilePath = outputPath; + const downloadedFilePath = outputPath // Check if the file exists and send it if (fs.existsSync(downloadedFilePath)) {