1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Fix peertube subtitles import

This commit is contained in:
Chocobozzz 2023-05-26 16:00:19 +02:00
parent c2eb81227b
commit c56dd2807f
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 20 additions and 5 deletions

View file

@ -2,6 +2,7 @@ import { UploadFilesForCheck } from 'express'
import { readFile } from 'fs-extra'
import { getFileSize } from '@shared/extra-utils'
import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants'
import { logger } from '../logger'
import { exists, isFileValid } from './misc'
function isVideoCaptionLanguageValid (value: any) {
@ -24,12 +25,13 @@ function isVideoCaptionFile (files: UploadFilesForCheck, field: string) {
async function isVTTFileValid (filePath: string) {
const size = await getFileSize(filePath)
const content = await readFile(filePath, 'utf8')
logger.debug('Checking VTT file %s', filePath, { size, content })
if (size > CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) return false
const content = await readFile(filePath, 'utf8')
return content?.startsWith('WEBVTT\n')
return content?.startsWith('WEBVTT')
}
// ---------------------------------------------------------------------------