mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Move video file metadata in their own table
Will be used for user video quotas and multiple video resolutions
This commit is contained in:
parent
69f224587e
commit
93e1258c7c
30 changed files with 818 additions and 340 deletions
|
@ -23,10 +23,11 @@ import {
|
|||
isVideoNSFWValid,
|
||||
isVideoDescriptionValid,
|
||||
isVideoDurationValid,
|
||||
isVideoInfoHashValid,
|
||||
isVideoFileInfoHashValid,
|
||||
isVideoNameValid,
|
||||
isVideoTagsValid,
|
||||
isVideoExtnameValid
|
||||
isVideoFileExtnameValid,
|
||||
isVideoFileResolutionValid
|
||||
} from '../videos'
|
||||
|
||||
const ENDPOINT_ACTIONS = REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS]
|
||||
|
@ -121,14 +122,22 @@ function isCommonVideoAttributesValid (video: any) {
|
|||
isVideoNSFWValid(video.nsfw) &&
|
||||
isVideoDescriptionValid(video.description) &&
|
||||
isVideoDurationValid(video.duration) &&
|
||||
isVideoInfoHashValid(video.infoHash) &&
|
||||
isVideoNameValid(video.name) &&
|
||||
isVideoTagsValid(video.tags) &&
|
||||
isVideoUUIDValid(video.uuid) &&
|
||||
isVideoExtnameValid(video.extname) &&
|
||||
isVideoViewsValid(video.views) &&
|
||||
isVideoLikesValid(video.likes) &&
|
||||
isVideoDislikesValid(video.dislikes)
|
||||
isVideoDislikesValid(video.dislikes) &&
|
||||
isArray(video.files) &&
|
||||
video.files.every(videoFile => {
|
||||
if (!videoFile) return false
|
||||
|
||||
return (
|
||||
isVideoFileInfoHashValid(videoFile.infoHash) &&
|
||||
isVideoFileExtnameValid(videoFile.extname) &&
|
||||
isVideoFileResolutionValid(videoFile.resolution)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function isRequestTypeAddValid (value: string) {
|
||||
|
|
|
@ -7,7 +7,8 @@ import {
|
|||
VIDEO_CATEGORIES,
|
||||
VIDEO_LICENCES,
|
||||
VIDEO_LANGUAGES,
|
||||
VIDEO_RATE_TYPES
|
||||
VIDEO_RATE_TYPES,
|
||||
VIDEO_FILE_RESOLUTIONS
|
||||
} from '../../initializers'
|
||||
import { isUserUsernameValid } from './users'
|
||||
import { isArray, exists } from './misc'
|
||||
|
@ -53,14 +54,6 @@ function isVideoDurationValid (value: string) {
|
|||
return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION)
|
||||
}
|
||||
|
||||
function isVideoExtnameValid (value: string) {
|
||||
return VIDEOS_CONSTRAINTS_FIELDS.EXTNAME.indexOf(value) !== -1
|
||||
}
|
||||
|
||||
function isVideoInfoHashValid (value: string) {
|
||||
return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)
|
||||
}
|
||||
|
||||
function isVideoNameValid (value: string) {
|
||||
return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME)
|
||||
}
|
||||
|
@ -128,6 +121,22 @@ function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Mul
|
|||
return new RegExp('^video/(webm|mp4|ogg)$', 'i').test(file.mimetype)
|
||||
}
|
||||
|
||||
function isVideoFileSizeValid (value: string) {
|
||||
return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.FILE_SIZE)
|
||||
}
|
||||
|
||||
function isVideoFileResolutionValid (value: string) {
|
||||
return VIDEO_FILE_RESOLUTIONS[value] !== undefined
|
||||
}
|
||||
|
||||
function isVideoFileExtnameValid (value: string) {
|
||||
return VIDEOS_CONSTRAINTS_FIELDS.EXTNAME.indexOf(value) !== -1
|
||||
}
|
||||
|
||||
function isVideoFileInfoHashValid (value: string) {
|
||||
return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
|
@ -140,12 +149,12 @@ export {
|
|||
isVideoNSFWValid,
|
||||
isVideoDescriptionValid,
|
||||
isVideoDurationValid,
|
||||
isVideoInfoHashValid,
|
||||
isVideoFileInfoHashValid,
|
||||
isVideoNameValid,
|
||||
isVideoTagsValid,
|
||||
isVideoThumbnailValid,
|
||||
isVideoThumbnailDataValid,
|
||||
isVideoExtnameValid,
|
||||
isVideoFileExtnameValid,
|
||||
isVideoUUIDValid,
|
||||
isVideoAbuseReasonValid,
|
||||
isVideoAbuseReporterUsernameValid,
|
||||
|
@ -154,7 +163,9 @@ export {
|
|||
isVideoLikesValid,
|
||||
isVideoRatingTypeValid,
|
||||
isVideoDislikesValid,
|
||||
isVideoEventCountValid
|
||||
isVideoEventCountValid,
|
||||
isVideoFileSizeValid,
|
||||
isVideoFileResolutionValid
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
@ -183,7 +194,9 @@ declare global {
|
|||
isVideoLikesValid,
|
||||
isVideoRatingTypeValid,
|
||||
isVideoDislikesValid,
|
||||
isVideoEventCountValid
|
||||
isVideoEventCountValid,
|
||||
isVideoFileSizeValid,
|
||||
isVideoFileResolutionValid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue