aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/index.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 9e233a8cc..49f0e4630 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -16,7 +16,8 @@ import {
16 quickAndDirtyUpdateVideoToFriends, 16 quickAndDirtyUpdateVideoToFriends,
17 addVideoToFriends, 17 addVideoToFriends,
18 updateVideoToFriends, 18 updateVideoToFriends,
19 JobScheduler 19 JobScheduler,
20 fetchRemoteDescription
20} from '../../../lib' 21} from '../../../lib'
21import { 22import {
22 authenticate, 23 authenticate,
@@ -102,6 +103,11 @@ videosRouter.post('/upload',
102 videosAddValidator, 103 videosAddValidator,
103 asyncMiddleware(addVideoRetryWrapper) 104 asyncMiddleware(addVideoRetryWrapper)
104) 105)
106
107videosRouter.get('/:id/description',
108 videosGetValidator,
109 asyncMiddleware(getVideoDescription)
110)
105videosRouter.get('/:id', 111videosRouter.get('/:id',
106 videosGetValidator, 112 videosGetValidator,
107 getVideo 113 getVideo
@@ -328,6 +334,19 @@ function getVideo (req: express.Request, res: express.Response) {
328 return res.json(videoInstance.toFormattedDetailsJSON()) 334 return res.json(videoInstance.toFormattedDetailsJSON())
329} 335}
330 336
337async function getVideoDescription (req: express.Request, res: express.Response) {
338 const videoInstance = res.locals.video
339 let description = ''
340
341 if (videoInstance.isOwned()) {
342 description = videoInstance.description
343 } else {
344 description = await fetchRemoteDescription(videoInstance)
345 }
346
347 return res.json({ description })
348}
349
331async function listVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 350async function listVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
332 const resultList = await db.Video.listForApi(req.query.start, req.query.count, req.query.sort) 351 const resultList = await db.Video.listForApi(req.query.start, req.query.count, req.query.sort)
333 352