Ajouter une route pour rendre une vidéo par ID avec gestion des erreurs
This commit is contained in:
@@ -277,5 +277,45 @@ router.get('/videos/file/:video_id', (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /videos/render/{video_id}:
|
||||
* post:
|
||||
* summary: Render a video by video ID
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: video_id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: The video ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Render process started
|
||||
* 404:
|
||||
* description: Video not found
|
||||
* 500:
|
||||
* description: Server error
|
||||
*/
|
||||
router.post('/videos/render/:video_id', (req, res) => {
|
||||
const videoId = req.params.video_id;
|
||||
const query = 'SELECT measurement_ids FROM public.videos WHERE id = $1';
|
||||
db.query(query, [videoId], (err, results) => {
|
||||
if (err) {
|
||||
return serverError.sendError('Error getting video:', res, err);
|
||||
}
|
||||
if (results.rows.length === 0) {
|
||||
return res.status(404).json({ error: 'Video not found' });
|
||||
}
|
||||
const measurementIds = results.rows[0].measurement_ids;
|
||||
videoManager.getPathList(measurementIds).then(pathList => {
|
||||
console.log('Path list:', pathList);
|
||||
res.json({ message: 'Render process started' });
|
||||
}).catch(err => {
|
||||
console.error('Error getting path list:', err);
|
||||
res.status(500).json({ error: 'Error getting path list' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user