diff --git a/routes/_utils/processClass.js b/routes/_utils/processClass.js index 713ea79..f7ab480 100644 --- a/routes/_utils/processClass.js +++ b/routes/_utils/processClass.js @@ -126,19 +126,21 @@ const convertVideoAndAudio = async (url,videoFormats,res) => { } } -const mergeVideoAndAudio = async (tempFilename, filename, response) => { +const mergeVideoAndAudio = async (formats, response) => { + const {filename,videoFilename, video_formats: {qualityLabel}} = formats const fullVid = new ffmpeg() - .addInput(Path.resolve(`./routes/api/files/${tempFilename}.mp4`)) - .addInput(Path.resolve(`./routes/api/files/${tempFilename}.mp3`)) - .saveToFile(Path.resolve(`./routes/api/files/${filename}.mp4`)) + .addInput(Path.resolve(`./routes/api/files/${filename}.mp4`)) + .addInput(Path.resolve(`./routes/api/files/${filename}.mp3`)) + .saveToFile(Path.resolve(`./routes/api/files/${videoFilename}.mp4`)) await new Promise((resolve, reject) => { fullVid.on('end', () => { resolve(JSON.stringify({ type: 'MERGE_AUDIO_AND_VIDEO_SUCCESSFULLY', payload: { - filePath: Path.resolve(`./routes/api/files/${filename}.mp4`), - filename: `${filename}.mp4` + filePath: Path.resolve(`./routes/api/files/${videoFilename}.mp4`), + filename: `${videoFilename}.mp4`, + quality: qualityLabel }, })) }) diff --git a/routes/api/ytdl.js b/routes/api/ytdl.js index 4c8c343..1c358ab 100644 --- a/routes/api/ytdl.js +++ b/routes/api/ytdl.js @@ -13,7 +13,7 @@ const { const getFilesizeInBytes = async (filename) => { let file = Fs.statSync(filename) let bytes = file["size"] - var size = (bytes / 1000000.0) - 1.1 + var size = bytes / 1000000.0 - 1.1 return size } @@ -47,7 +47,7 @@ router.get('/download/mp4', async (req, res) => { }) } - await mergeVideoAndAudio(videoFormats.filename,videoFormats.videoFilename, async (response) => { + await mergeVideoAndAudio(videoFormats, async (response) => { const action = JSON.parse(response) switch(action.type) { case 'MERGE_AUDIO_AND_VIDEO_SUCCESSFULLY': @@ -57,7 +57,8 @@ router.get('/download/mp4', async (req, res) => { type: action.type, filename: action.payload.filename, size: fileSize, - link: `/download/video/${action.payload.filename}` + link: `/download/video/${action.payload.filename}`, + quality: action.payload.quality, }) } catch(err) { res.json({ diff --git a/src/components/types/videoList.jsx b/src/components/types/videoList.jsx index 85bbea0..36288fe 100644 --- a/src/components/types/videoList.jsx +++ b/src/components/types/videoList.jsx @@ -14,7 +14,8 @@ class VideoList extends Component { link: '', filename:'', type:'', - size: 0 + size: 0, + quality: '' } render() { @@ -35,31 +36,33 @@ class VideoList extends Component { .{format.container} - {this.state.type.length === 0 ? - : - - } + {this.state.quality !== format.qualityLabel ? + + : + + } )