From 55697fc03294571ae4115eed95ec3205696d990f Mon Sep 17 00:00:00 2001 From: dakerboul Date: Mon, 10 Mar 2025 17:36:39 +0100 Subject: [PATCH] =?UTF-8?q?Modifier=20la=20fonction=20createVideoWithList?= =?UTF-8?q?=20pour=20inclure=20l'ID=20de=20la=20vid=C3=A9o=20et=20mettre?= =?UTF-8?q?=20=C3=A0=20jour=20le=20statut=20de=20la=20vid=C3=A9o=20apr?= =?UTF-8?q?=C3=A8s=20le=20rendu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/videoRoutes.js | 11 +---------- src/video/videoManager.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/routes/videoRoutes.js b/routes/videoRoutes.js index 03f55a6..9428b45 100644 --- a/routes/videoRoutes.js +++ b/routes/videoRoutes.js @@ -347,21 +347,12 @@ router.post('/videos/render/:video_id', async (req, res) => { console.log('Path list:', pathList); res.json({ message: 'Render process started' }); - const videoFile = await videoManager.createVideoWithList(project_id, pathList, duration); + const videoFile = await videoManager.createVideoWithList(project_id, pathList, duration, videoId); console.log('Video file:', videoFile); await videoManager.updateVideoFile(videoId, videoFile); console.log('Video rendering complete'); - - //changer status de la vidéo à 1 - const query = 'UPDATE public.videos SET status = 1 WHERE id = $1'; - db.query(query, [videoId], (err, results) => { - if (err) { - return serverError.sendError('Error updating video status:', res, err); - } - console.log('Video status updated:', results.rows[0]); - }); } catch (err) { console.error('Error during video rendering:', err); res.status(500).json({ error: 'Error during video rendering' }); diff --git a/src/video/videoManager.js b/src/video/videoManager.js index 6f4b7ce..2a5f346 100644 --- a/src/video/videoManager.js +++ b/src/video/videoManager.js @@ -27,7 +27,7 @@ async function deleteVideoProject(videoId) { return res.rows[0]; } -async function createVideoWithList(projectId, pathList, duration) { +async function createVideoWithList(projectId, pathList, duration, videoId) { const tempFile = path.join('temp.txt'); try { const workdir = path.join(PROJECTS_DIR, 'storage', `${projectId}`); @@ -89,6 +89,15 @@ async function createVideoWithList(projectId, pathList, duration) { fs.unlinkSync(tempFile); console.log('Temporary file deleted:', tempFile); } + + //changer status de la vidéo à 1 + const query = 'UPDATE public.videos SET status = 1 WHERE id = $1'; + db.query(query, [videoId], (err, results) => { + if (err) { + return serverError.sendError('Error updating video status:', res, err); + } + console.log('Video status updated:', results.rows[0]); + }); } }