From 92e66e04f7f51d37b465cff442ce47f6d6d7cadd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 22 Mar 2022 16:58:49 +0100 Subject: Rename studio to editor --- server/helpers/custom-validators/video-editor.ts | 52 ------------------------ server/helpers/custom-validators/video-studio.ts | 52 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 server/helpers/custom-validators/video-editor.ts create mode 100644 server/helpers/custom-validators/video-studio.ts (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/video-editor.ts b/server/helpers/custom-validators/video-editor.ts deleted file mode 100644 index 09238675e..000000000 --- a/server/helpers/custom-validators/video-editor.ts +++ /dev/null @@ -1,52 +0,0 @@ -import validator from 'validator' -import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' -import { buildTaskFileFieldname } from '@server/lib/video-editor' -import { VideoEditorTask } from '@shared/models' -import { isArray } from './misc' -import { isVideoFileMimeTypeValid, isVideoImageValid } from './videos' - -function isValidEditorTasksArray (tasks: any) { - if (!isArray(tasks)) return false - - return tasks.length >= CONSTRAINTS_FIELDS.VIDEO_EDITOR.TASKS.min && - tasks.length <= CONSTRAINTS_FIELDS.VIDEO_EDITOR.TASKS.max -} - -function isEditorCutTaskValid (task: VideoEditorTask) { - if (task.name !== 'cut') return false - if (!task.options) return false - - const { start, end } = task.options - if (!start && !end) return false - - if (start && !validator.isInt(start + '', CONSTRAINTS_FIELDS.VIDEO_EDITOR.CUT_TIME)) return false - if (end && !validator.isInt(end + '', CONSTRAINTS_FIELDS.VIDEO_EDITOR.CUT_TIME)) return false - - if (!start || !end) return true - - return parseInt(start + '') < parseInt(end + '') -} - -function isEditorTaskAddIntroOutroValid (task: VideoEditorTask, indice: number, files: Express.Multer.File[]) { - const file = files.find(f => f.fieldname === buildTaskFileFieldname(indice, 'file')) - - return (task.name === 'add-intro' || task.name === 'add-outro') && - file && isVideoFileMimeTypeValid([ file ], null) -} - -function isEditorTaskAddWatermarkValid (task: VideoEditorTask, indice: number, files: Express.Multer.File[]) { - const file = files.find(f => f.fieldname === buildTaskFileFieldname(indice, 'file')) - - return task.name === 'add-watermark' && - file && isVideoImageValid([ file ], null, true) -} - -// --------------------------------------------------------------------------- - -export { - isValidEditorTasksArray, - - isEditorCutTaskValid, - isEditorTaskAddIntroOutroValid, - isEditorTaskAddWatermarkValid -} diff --git a/server/helpers/custom-validators/video-studio.ts b/server/helpers/custom-validators/video-studio.ts new file mode 100644 index 000000000..19e7906d5 --- /dev/null +++ b/server/helpers/custom-validators/video-studio.ts @@ -0,0 +1,52 @@ +import validator from 'validator' +import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' +import { buildTaskFileFieldname } from '@server/lib/video-studio' +import { VideoStudioTask } from '@shared/models' +import { isArray } from './misc' +import { isVideoFileMimeTypeValid, isVideoImageValid } from './videos' + +function isValidStudioTasksArray (tasks: any) { + if (!isArray(tasks)) return false + + return tasks.length >= CONSTRAINTS_FIELDS.VIDEO_STUDIO.TASKS.min && + tasks.length <= CONSTRAINTS_FIELDS.VIDEO_STUDIO.TASKS.max +} + +function isStudioCutTaskValid (task: VideoStudioTask) { + if (task.name !== 'cut') return false + if (!task.options) return false + + const { start, end } = task.options + if (!start && !end) return false + + if (start && !validator.isInt(start + '', CONSTRAINTS_FIELDS.VIDEO_STUDIO.CUT_TIME)) return false + if (end && !validator.isInt(end + '', CONSTRAINTS_FIELDS.VIDEO_STUDIO.CUT_TIME)) return false + + if (!start || !end) return true + + return parseInt(start + '') < parseInt(end + '') +} + +function isStudioTaskAddIntroOutroValid (task: VideoStudioTask, indice: number, files: Express.Multer.File[]) { + const file = files.find(f => f.fieldname === buildTaskFileFieldname(indice, 'file')) + + return (task.name === 'add-intro' || task.name === 'add-outro') && + file && isVideoFileMimeTypeValid([ file ], null) +} + +function isStudioTaskAddWatermarkValid (task: VideoStudioTask, indice: number, files: Express.Multer.File[]) { + const file = files.find(f => f.fieldname === buildTaskFileFieldname(indice, 'file')) + + return task.name === 'add-watermark' && + file && isVideoImageValid([ file ], null, true) +} + +// --------------------------------------------------------------------------- + +export { + isValidStudioTasksArray, + + isStudioCutTaskValid, + isStudioTaskAddIntroOutroValid, + isStudioTaskAddWatermarkValid +} -- cgit v1.2.3