aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-03-10 14:39:40 +0100
committerGitHub <noreply@github.com>2020-03-10 14:39:40 +0100
commit8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4 (patch)
tree1f87041b2cd76222844960602cdc9f52fe206c7b /server/middlewares/validators
parentedb868655e52f934a71141175cf9dc6cb4753e11 (diff)
downloadPeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.gz
PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.zst
PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.zip
Add video file metadata to download modal, via ffprobe (#2411)
* Add video file metadata via ffprobe * Federate video file metadata * Add tests for file metadata generation * Complete tests for videoFile metadata federation * Lint migration and video-file for metadata * Objectify metadata from getter in ffmpeg-utils * Add metadataUrl to all videoFiles * Simplify metadata API middleware * Load playlist in videoFile when requesting metadata
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/videos/videos.ts22
1 files changed, 21 insertions, 1 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index a027c4840..96e0d6600 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -42,7 +42,12 @@ import { getServerActor } from '../../../helpers/utils'
42import { CONFIG } from '../../../initializers/config' 42import { CONFIG } from '../../../initializers/config'
43import { isLocalVideoAccepted } from '../../../lib/moderation' 43import { isLocalVideoAccepted } from '../../../lib/moderation'
44import { Hooks } from '../../../lib/plugins/hooks' 44import { Hooks } from '../../../lib/plugins/hooks'
45import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../../../helpers/middlewares' 45import {
46 checkUserCanManageVideo,
47 doesVideoChannelOfAccountExist,
48 doesVideoExist,
49 doesVideoFileOfVideoExist
50} from '../../../helpers/middlewares'
46import { MVideoFullLight } from '@server/typings/models' 51import { MVideoFullLight } from '@server/typings/models'
47import { getVideoWithAttributes } from '../../../helpers/video' 52import { getVideoWithAttributes } from '../../../helpers/video'
48 53
@@ -198,6 +203,20 @@ const videosCustomGetValidator = (
198const videosGetValidator = videosCustomGetValidator('all') 203const videosGetValidator = videosCustomGetValidator('all')
199const videosDownloadValidator = videosCustomGetValidator('all', true) 204const videosDownloadValidator = videosCustomGetValidator('all', true)
200 205
206const videoFileMetadataGetValidator = getCommonVideoEditAttributes().concat([
207 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
208 param('videoFileId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid videoFileId'),
209
210 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
211 logger.debug('Checking videoFileMetadataGet parameters', { parameters: req.params })
212
213 if (areValidationErrors(req, res)) return
214 if (!await doesVideoFileOfVideoExist(+req.params.videoFileId, req.params.id, res)) return
215
216 return next()
217 }
218])
219
201const videosRemoveValidator = [ 220const videosRemoveValidator = [
202 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), 221 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
203 222
@@ -411,6 +430,7 @@ export {
411 videosAddValidator, 430 videosAddValidator,
412 videosUpdateValidator, 431 videosUpdateValidator,
413 videosGetValidator, 432 videosGetValidator,
433 videoFileMetadataGetValidator,
414 videosDownloadValidator, 434 videosDownloadValidator,
415 checkVideoFollowConstraints, 435 checkVideoFollowConstraints,
416 videosCustomGetValidator, 436 videosCustomGetValidator,