X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fcontrollers%2Fapi%2Fv1%2Fvideos.js;h=f7aeea4532e711aff477b6eca79f83134536789e;hb=68ce3ae021c9bc11b155044df6d23ba60e91eee4;hp=e903cbcf4135950da1dd89769a88f75ebbcd1fb3;hpb=501bc6c2b186f6a724a5b619d15aa44791f13995;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index e903cbcf4..f7aeea453 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js @@ -62,7 +62,7 @@ router.post('/', ) router.get('/:id', reqValidatorVideos.videosGet, - getVideos + getVideo ) router.delete('/:id', oAuth2.authenticate, @@ -165,7 +165,7 @@ function addVideo (req, res, next) { }) } -function getVideos (req, res, next) { +function getVideo (req, res, next) { Videos.get(req.params.id, function (err, videoObj) { if (err) return next(err) @@ -179,10 +179,10 @@ function getVideos (req, res, next) { } function listVideos (req, res, next) { - Videos.list(req.query.start, req.query.count, req.query.sort, function (err, videosList) { + Videos.list(req.query.start, req.query.count, req.query.sort, function (err, videosList, totalVideos) { if (err) return next(err) - res.json(getFormatedVideos(videosList)) + res.json(getFormatedVideos(videosList, totalVideos)) }) } @@ -237,10 +237,10 @@ function removeVideo (req, res, next) { } function searchVideos (req, res, next) { - Videos.search(req.params.name, req.query.start, req.query.count, req.query.sort, function (err, videosList) { + Videos.search(req.params.name, req.query.start, req.query.count, req.query.sort, function (err, videosList, totalVideos) { if (err) return next(err) - res.json(getFormatedVideos(videosList)) + res.json(getFormatedVideos(videosList, totalVideos)) }) } @@ -263,14 +263,17 @@ function getFormatedVideo (videoObj) { return formatedVideo } -function getFormatedVideos (videosObj) { +function getFormatedVideos (videosObj, totalVideos) { const formatedVideos = [] videosObj.forEach(function (videoObj) { formatedVideos.push(getFormatedVideo(videoObj)) }) - return formatedVideos + return { + total: totalVideos, + data: formatedVideos + } } // Maybe the torrent is not seeded, but we catch the error to don't stop the removing process