mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Support additional video extensions
This commit is contained in:
parent
8923187455
commit
14e2014acc
39 changed files with 268 additions and 90 deletions
|
@ -1,4 +1,4 @@
|
|||
import { CONSTRAINTS_FIELDS, VIDEO_CAPTIONS_MIMETYPE_EXT, VIDEO_LANGUAGES } from '../../initializers'
|
||||
import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers'
|
||||
import { exists, isFileValid } from './misc'
|
||||
import { Response } from 'express'
|
||||
import { VideoModel } from '../../models/video/video'
|
||||
|
@ -8,7 +8,7 @@ function isVideoCaptionLanguageValid (value: any) {
|
|||
return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined
|
||||
}
|
||||
|
||||
const videoCaptionTypes = Object.keys(VIDEO_CAPTIONS_MIMETYPE_EXT)
|
||||
const videoCaptionTypes = Object.keys(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT)
|
||||
.concat([ 'application/octet-stream' ]) // MacOS sends application/octet-stream ><
|
||||
.map(m => `(${m})`)
|
||||
const videoCaptionTypesRegex = videoCaptionTypes.join('|')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'express-validator'
|
||||
import 'multer'
|
||||
import * as validator from 'validator'
|
||||
import { CONSTRAINTS_FIELDS, TORRENT_MIMETYPE_EXT, VIDEO_IMPORT_STATES } from '../../initializers'
|
||||
import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers'
|
||||
import { exists, isFileValid } from './misc'
|
||||
import * as express from 'express'
|
||||
import { VideoImportModel } from '../../models/video/video-import'
|
||||
|
@ -24,7 +24,7 @@ function isVideoImportStateValid (value: any) {
|
|||
return exists(value) && VIDEO_IMPORT_STATES[ value ] !== undefined
|
||||
}
|
||||
|
||||
const videoTorrentImportTypes = Object.keys(TORRENT_MIMETYPE_EXT).map(m => `(${m})`)
|
||||
const videoTorrentImportTypes = Object.keys(MIMETYPES.TORRENT.MIMETYPE_EXT).map(m => `(${m})`)
|
||||
const videoTorrentImportRegex = videoTorrentImportTypes.join('|')
|
||||
function isVideoImportTorrentFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[]) {
|
||||
return isFileValid(files, videoTorrentImportRegex, 'torrentfile', CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_FILE.FILE_SIZE.max, true)
|
||||
|
|
|
@ -5,10 +5,9 @@ import 'multer'
|
|||
import * as validator from 'validator'
|
||||
import { UserRight, VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
|
||||
import {
|
||||
CONSTRAINTS_FIELDS,
|
||||
CONSTRAINTS_FIELDS, MIMETYPES,
|
||||
VIDEO_CATEGORIES,
|
||||
VIDEO_LICENCES,
|
||||
VIDEO_MIMETYPE_EXT,
|
||||
VIDEO_PRIVACIES,
|
||||
VIDEO_RATE_TYPES,
|
||||
VIDEO_STATES
|
||||
|
@ -83,10 +82,15 @@ function isVideoRatingTypeValid (value: string) {
|
|||
return value === 'none' || values(VIDEO_RATE_TYPES).indexOf(value as VideoRateType) !== -1
|
||||
}
|
||||
|
||||
const videoFileTypes = Object.keys(VIDEO_MIMETYPE_EXT).map(m => `(${m})`)
|
||||
const videoFileTypesRegex = videoFileTypes.join('|')
|
||||
function isVideoFileExtnameValid (value: string) {
|
||||
return exists(value) && MIMETYPES.VIDEO.EXT_MIMETYPE[value] !== undefined
|
||||
}
|
||||
|
||||
function isVideoFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[]) {
|
||||
const videoFileTypesRegex = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT)
|
||||
.map(m => `(${m})`)
|
||||
.join('|')
|
||||
|
||||
return isFileValid(files, videoFileTypesRegex, 'videofile', null)
|
||||
}
|
||||
|
||||
|
@ -221,6 +225,7 @@ export {
|
|||
isVideoStateValid,
|
||||
isVideoViewsValid,
|
||||
isVideoRatingTypeValid,
|
||||
isVideoFileExtnameValid,
|
||||
isVideoDurationValid,
|
||||
isVideoTagValid,
|
||||
isVideoPrivacyValid,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue