aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-26 16:00:19 +0200
committerChocobozzz <me@florianbigard.com>2023-05-26 16:05:08 +0200
commitc56dd2807fe5d129907b9bf8c42656a8314d754b (patch)
treebd1b11237484bdb81d64bc29c87fcbdcb66e5ea0 /server/helpers/custom-validators
parentc2eb81227b31d15c894b110d090308a9e3ac0606 (diff)
downloadPeerTube-c56dd2807fe5d129907b9bf8c42656a8314d754b.tar.gz
PeerTube-c56dd2807fe5d129907b9bf8c42656a8314d754b.tar.zst
PeerTube-c56dd2807fe5d129907b9bf8c42656a8314d754b.zip
Fix peertube subtitles import
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/video-captions.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/server/helpers/custom-validators/video-captions.ts b/server/helpers/custom-validators/video-captions.ts
index d5b09ea03..0e24655a0 100644
--- a/server/helpers/custom-validators/video-captions.ts
+++ b/server/helpers/custom-validators/video-captions.ts
@@ -2,6 +2,7 @@ import { UploadFilesForCheck } from 'express'
2import { readFile } from 'fs-extra' 2import { readFile } from 'fs-extra'
3import { getFileSize } from '@shared/extra-utils' 3import { getFileSize } from '@shared/extra-utils'
4import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' 4import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants'
5import { logger } from '../logger'
5import { exists, isFileValid } from './misc' 6import { exists, isFileValid } from './misc'
6 7
7function isVideoCaptionLanguageValid (value: any) { 8function isVideoCaptionLanguageValid (value: any) {
@@ -24,12 +25,13 @@ function isVideoCaptionFile (files: UploadFilesForCheck, field: string) {
24 25
25async function isVTTFileValid (filePath: string) { 26async function isVTTFileValid (filePath: string) {
26 const size = await getFileSize(filePath) 27 const size = await getFileSize(filePath)
28 const content = await readFile(filePath, 'utf8')
27 29
28 if (size > CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) return false 30 logger.debug('Checking VTT file %s', filePath, { size, content })
29 31
30 const content = await readFile(filePath, 'utf8') 32 if (size > CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) return false
31 33
32 return content?.startsWith('WEBVTT\n') 34 return content?.startsWith('WEBVTT')
33} 35}
34 36
35// --------------------------------------------------------------------------- 37// ---------------------------------------------------------------------------