diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-26 16:00:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-26 16:05:08 +0200 |
commit | c56dd2807fe5d129907b9bf8c42656a8314d754b (patch) | |
tree | bd1b11237484bdb81d64bc29c87fcbdcb66e5ea0 /server/helpers | |
parent | c2eb81227b31d15c894b110d090308a9e3ac0606 (diff) | |
download | PeerTube-c56dd2807fe5d129907b9bf8c42656a8314d754b.tar.gz PeerTube-c56dd2807fe5d129907b9bf8c42656a8314d754b.tar.zst PeerTube-c56dd2807fe5d129907b9bf8c42656a8314d754b.zip |
Fix peertube subtitles import
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/video-captions.ts | 8 |
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' | |||
2 | import { readFile } from 'fs-extra' | 2 | import { readFile } from 'fs-extra' |
3 | import { getFileSize } from '@shared/extra-utils' | 3 | import { getFileSize } from '@shared/extra-utils' |
4 | import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' | 4 | import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' |
5 | import { logger } from '../logger' | ||
5 | import { exists, isFileValid } from './misc' | 6 | import { exists, isFileValid } from './misc' |
6 | 7 | ||
7 | function isVideoCaptionLanguageValid (value: any) { | 8 | function isVideoCaptionLanguageValid (value: any) { |
@@ -24,12 +25,13 @@ function isVideoCaptionFile (files: UploadFilesForCheck, field: string) { | |||
24 | 25 | ||
25 | async function isVTTFileValid (filePath: string) { | 26 | async 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 | // --------------------------------------------------------------------------- |