aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/v1
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/v1')
-rw-r--r--server/controllers/api/v1/videos.js19
1 files changed, 11 insertions, 8 deletions
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('/',
62) 62)
63router.get('/:id', 63router.get('/:id',
64 reqValidatorVideos.videosGet, 64 reqValidatorVideos.videosGet,
65 getVideos 65 getVideo
66) 66)
67router.delete('/:id', 67router.delete('/:id',
68 oAuth2.authenticate, 68 oAuth2.authenticate,
@@ -165,7 +165,7 @@ function addVideo (req, res, next) {
165 }) 165 })
166} 166}
167 167
168function getVideos (req, res, next) { 168function getVideo (req, res, next) {
169 Videos.get(req.params.id, function (err, videoObj) { 169 Videos.get(req.params.id, function (err, videoObj) {
170 if (err) return next(err) 170 if (err) return next(err)
171 171
@@ -179,10 +179,10 @@ function getVideos (req, res, next) {
179} 179}
180 180
181function listVideos (req, res, next) { 181function listVideos (req, res, next) {
182 Videos.list(req.query.start, req.query.count, req.query.sort, function (err, videosList) { 182 Videos.list(req.query.start, req.query.count, req.query.sort, function (err, videosList, totalVideos) {
183 if (err) return next(err) 183 if (err) return next(err)
184 184
185 res.json(getFormatedVideos(videosList)) 185 res.json(getFormatedVideos(videosList, totalVideos))
186 }) 186 })
187} 187}
188 188
@@ -237,10 +237,10 @@ function removeVideo (req, res, next) {
237} 237}
238 238
239function searchVideos (req, res, next) { 239function searchVideos (req, res, next) {
240 Videos.search(req.params.name, req.query.start, req.query.count, req.query.sort, function (err, videosList) { 240 Videos.search(req.params.name, req.query.start, req.query.count, req.query.sort, function (err, videosList, totalVideos) {
241 if (err) return next(err) 241 if (err) return next(err)
242 242
243 res.json(getFormatedVideos(videosList)) 243 res.json(getFormatedVideos(videosList, totalVideos))
244 }) 244 })
245} 245}
246 246
@@ -263,14 +263,17 @@ function getFormatedVideo (videoObj) {
263 return formatedVideo 263 return formatedVideo
264} 264}
265 265
266function getFormatedVideos (videosObj) { 266function getFormatedVideos (videosObj, totalVideos) {
267 const formatedVideos = [] 267 const formatedVideos = []
268 268
269 videosObj.forEach(function (videoObj) { 269 videosObj.forEach(function (videoObj) {
270 formatedVideos.push(getFormatedVideo(videoObj)) 270 formatedVideos.push(getFormatedVideo(videoObj))
271 }) 271 })
272 272
273 return formatedVideos 273 return {
274 total: totalVideos,
275 data: formatedVideos
276 }
274} 277}
275 278
276// Maybe the torrent is not seeded, but we catch the error to don't stop the removing process 279// Maybe the torrent is not seeded, but we catch the error to don't stop the removing process