aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-16 14:22:16 +0200
committerChocobozzz <me@florianbigard.com>2018-07-16 14:31:40 +0200
commitf4001cf408a99049d01a356bfb20a62342de06ea (patch)
tree421776dfe64335dca2725ac3ac5f3b3e6b7564c6 /server/helpers/custom-validators
parent16f7022b06fb76c0b00c23c970bc8df605b0ec63 (diff)
downloadPeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.tar.gz
PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.tar.zst
PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.zip
Handle .srt subtitles
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/video-captions.ts11
1 files changed, 4 insertions, 7 deletions
diff --git a/server/helpers/custom-validators/video-captions.ts b/server/helpers/custom-validators/video-captions.ts
index fd4dc740b..6a9c6d75c 100644
--- a/server/helpers/custom-validators/video-captions.ts
+++ b/server/helpers/custom-validators/video-captions.ts
@@ -1,4 +1,4 @@
1import { CONSTRAINTS_FIELDS, VIDEO_LANGUAGES } from '../../initializers' 1import { CONSTRAINTS_FIELDS, VIDEO_CAPTIONS_MIMETYPE_EXT, VIDEO_LANGUAGES, VIDEO_MIMETYPE_EXT } from '../../initializers'
2import { exists, isFileValid } from './misc' 2import { exists, isFileValid } from './misc'
3import { Response } from 'express' 3import { Response } from 'express'
4import { VideoModel } from '../../models/video/video' 4import { VideoModel } from '../../models/video/video'
@@ -8,13 +8,10 @@ function isVideoCaptionLanguageValid (value: any) {
8 return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined 8 return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined
9} 9}
10 10
11const videoCaptionTypes = CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME 11const videoCaptionTypes = Object.keys(VIDEO_CAPTIONS_MIMETYPE_EXT).map(m => `(${m})`)
12 .map(v => v.replace('.', '')) 12const videoCaptionTypesRegex = videoCaptionTypes.join('|')
13 .join('|')
14const videoCaptionsTypesRegex = `text/(${videoCaptionTypes})`
15
16function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], field: string) { 13function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], field: string) {
17 return isFileValid(files, videoCaptionsTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) 14 return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max)
18} 15}
19 16
20async function isVideoCaptionExist (video: VideoModel, language: string, res: Response) { 17async function isVideoCaptionExist (video: VideoModel, language: string, res: Response) {