mirror of https://github.com/Chocobozzz/PeerTube
Removed DuratonMax
parent
b2fa2e84f7
commit
fddb02ea55
|
@ -66,6 +66,7 @@
|
|||
"tsc": "tsc",
|
||||
"commander": "commander",
|
||||
"lint": "npm run ci -- lint",
|
||||
|
||||
"ng": "ng",
|
||||
"tsx": "tsx",
|
||||
"eslint": "eslint",
|
||||
|
|
|
@ -37,7 +37,6 @@ export interface VideosCommonQuery {
|
|||
|
||||
excludeAlreadyWatched?: boolean
|
||||
|
||||
durationMax?: number /*EDITED*/
|
||||
shortVideo?: boolean
|
||||
}
|
||||
|
||||
|
|
|
@ -101,8 +101,6 @@ async function addVideoLegacy (req: express.Request, res: express.Response) {
|
|||
// Uploading the video could be long
|
||||
// Set timeout to 10 minutes, as Express's default is 2 minutes
|
||||
|
||||
|
||||
|
||||
req.setTimeout(1000 * 60 * 10, () => {
|
||||
logger.error('Video upload has timed out.')
|
||||
return res.fail({
|
||||
|
@ -145,7 +143,6 @@ async function addVideo (options: {
|
|||
let videoData = buildLocalVideoFromReq(videoInfo, videoChannel.id)
|
||||
videoData = await Hooks.wrapObject(videoData, 'filter:api.video.upload.video-attribute.result')
|
||||
|
||||
|
||||
videoData.state = buildNextVideoState()
|
||||
videoData.duration = videoPhysicalFile.duration // duration was added by a previous middleware
|
||||
|
||||
|
|
|
@ -185,10 +185,9 @@ function isValidPasswordProtectedPrivacy (req: Request, res: Response) {
|
|||
return true
|
||||
}
|
||||
|
||||
function isDurationValid (currDuration: number, requiredDuration: number) {
|
||||
|
||||
function isDurationValid(currDuration : number, requiredDuration: number){
|
||||
|
||||
return currDuration<= requiredDuration;
|
||||
return currDuration <= requiredDuration
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -27,7 +27,6 @@ function pickCommonVideoQuery (query: VideosCommonQueryAfterSanitize) {
|
|||
'hasWebVideoFiles',
|
||||
'search',
|
||||
'excludeAlreadyWatched',
|
||||
'durationMax',
|
||||
'shortVideo'
|
||||
])
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ export function buildLocalVideoFromReq (videoInfo: VideoCreate, channelId: numbe
|
|||
? new Date(videoInfo.originallyPublishedAt)
|
||||
: null,
|
||||
|
||||
shortVideo: videoInfo.shortVideo || false
|
||||
shortVideo: videoInfo.shortVideo || false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ import {
|
|||
} from '../shared/index.js'
|
||||
import { addDurationToVideoFileIfNeeded, commonVideoFileChecks, isVideoFileAccepted } from './shared/index.js'
|
||||
|
||||
|
||||
// let duration: number
|
||||
|
||||
const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([
|
||||
|
@ -75,8 +74,6 @@ const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([
|
|||
.isArray()
|
||||
.withMessage('Video passwords should be an array.'),
|
||||
|
||||
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
||||
|
||||
|
@ -87,14 +84,12 @@ const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([
|
|||
!await commonVideoChecksPass({ req, res, user, videoFileSize: videoFile.size, files: req.files }) ||
|
||||
!isValidPasswordProtectedPrivacy(req, res) ||
|
||||
!await addDurationToVideoFileIfNeeded({ videoFile, res, middlewareName: 'videosAddvideosAddLegacyValidatorResumableValidator' }) ||
|
||||
!await isVideoFileAccepted({ req, res, videoFile, hook: 'filter:api.video.upload.accept.result' }) ) {
|
||||
!await isVideoFileAccepted({ req, res, videoFile, hook: 'filter:api.video.upload.accept.result' })) {
|
||||
return cleanUpReqFiles(req)
|
||||
}
|
||||
|
||||
return next()
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
|
||||
])
|
||||
|
||||
|
@ -361,45 +356,27 @@ const videosOverviewValidator = [
|
|||
}
|
||||
]
|
||||
|
||||
|
||||
|
||||
function getCommonVideoEditAttributes () {
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req);
|
||||
|
||||
const videoFile: express.VideoUploadFile = req.files['videofile'][0];
|
||||
const user = res.locals.oauth.token.User;
|
||||
|
||||
if (
|
||||
!await commonVideoChecksPass({ req, res, user, videoFileSize: videoFile.size, files: req.files }) ||
|
||||
!isValidPasswordProtectedPrivacy(req, res) ||
|
||||
!await addDurationToVideoFileIfNeeded({ videoFile, res, middlewareName: 'videosAddvideosAddLegacyValidatorResumableValidator' }) ||
|
||||
!await isVideoFileAccepted({ req, res, videoFile, hook: 'filter:api.video.upload.accept.result' })
|
||||
) {
|
||||
return cleanUpReqFiles(req);
|
||||
}
|
||||
|
||||
};
|
||||
return [
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req);
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
||||
|
||||
const videoFile: express.VideoUploadFile = req.files['videofile'][0];
|
||||
const user = res.locals.oauth.token.User;
|
||||
const videoFile: express.VideoUploadFile = req.files['videofile'][0]
|
||||
const user = res.locals.oauth.token.User
|
||||
|
||||
if (
|
||||
!await commonVideoChecksPass({ req, res, user, videoFileSize: videoFile.size, files: req.files }) ||
|
||||
if (
|
||||
!await commonVideoChecksPass({ req, res, user, videoFileSize: videoFile.size, files: req.files }) ||
|
||||
!isValidPasswordProtectedPrivacy(req, res) ||
|
||||
!await addDurationToVideoFileIfNeeded({ videoFile, res, middlewareName: 'videosAddvideosAddLegacyValidatorResumableValidator' }) ||
|
||||
!await isVideoFileAccepted({ req, res, videoFile, hook: 'filter:api.video.upload.accept.result' })
|
||||
) {
|
||||
return cleanUpReqFiles(req);
|
||||
}
|
||||
) {
|
||||
return cleanUpReqFiles(req)
|
||||
}
|
||||
|
||||
return next();
|
||||
},
|
||||
return next()
|
||||
},
|
||||
|
||||
body('thumbnailfile')
|
||||
.custom((value, { req }) => isVideoImageValid(req.files, 'thumbnailfile')).withMessage(
|
||||
|
@ -474,27 +451,19 @@ async (req: express.Request, res: express.Response, next: express.NextFunction)
|
|||
.optional()
|
||||
.customSanitizer(toIntOrNull)
|
||||
.custom(isScheduleVideoUpdatePrivacyValid),
|
||||
|
||||
|
||||
body('shortVideo')
|
||||
.optional()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(() => true).withMessage('Should have shortVideo boolean'),
|
||||
|
||||
body('shortVideo')
|
||||
.optional()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
|
||||
.custom((value, { req }) => {
|
||||
if (value) {
|
||||
const videoFile: express.VideoUploadFile = req.files['videofile'][0]
|
||||
|
||||
return isDurationValid(videoFile.duration, 20);
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.withMessage('Video duration must be less than 60 seconds for short videos'),
|
||||
.custom(isBooleanValid).withMessage('Should have shortVideo boolean'),
|
||||
body('shortVideo')
|
||||
.custom((value, { req }) => {
|
||||
if (value) {
|
||||
const videoFile: express.VideoUploadFile = req.files['videofile'][0]
|
||||
|
||||
return isDurationValid(videoFile.duration, 60)
|
||||
}
|
||||
return true
|
||||
}).withMessage('Video duration must be less than 60 seconds for short videos')
|
||||
|
||||
] as (ValidationChain | ExpressPromiseHandler)[]
|
||||
}
|
||||
|
@ -528,9 +497,7 @@ const commonVideosFiltersValidator = [
|
|||
.optional()
|
||||
.custom(isBooleanBothQueryValid),
|
||||
|
||||
|
||||
|
||||
query('shortVideo')
|
||||
query('shortVideo')
|
||||
.optional()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(isBooleanValid).withMessage('Should have a valid shortVideo boolean'),
|
||||
|
|
|
@ -266,7 +266,8 @@ export class VideoTableAttributes {
|
|||
'channelId',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'moveJobsRunning'
|
||||
'moveJobsRunning',
|
||||
'shortVideo'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,14 +214,12 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
|
|||
this.whereSFW()
|
||||
}
|
||||
|
||||
if(options.shortVideo === true){
|
||||
if (options.shortVideo === true) {
|
||||
this.whereShortVideo()
|
||||
}
|
||||
else if(options.shortVideo == false){
|
||||
} else if (options.shortVideo === false) {
|
||||
this.whereLongVideo()
|
||||
}
|
||||
|
||||
|
||||
if (options.isLive === true) {
|
||||
this.whereLive()
|
||||
} else if (options.isLive === false) {
|
||||
|
@ -525,13 +523,13 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
|
|||
this.and.push('"video"."nsfw" IS FALSE')
|
||||
}
|
||||
|
||||
private whereShortVideo(){
|
||||
private whereShortVideo () {
|
||||
this.and.push('"video"."shortVideo" IS TRUE')
|
||||
}
|
||||
|
||||
private whereLongVideo(){
|
||||
this.and.push('"video"."shortVideo" IS FALSE')
|
||||
}
|
||||
private whereLongVideo () {
|
||||
this.and.push('"video"."shortVideo" IS FALSE')
|
||||
}
|
||||
|
||||
private whereLive () {
|
||||
this.and.push('"video"."isLive" IS TRUE')
|
||||
|
|
|
@ -37,6 +37,9 @@ export class VideosModelListQueryBuilder extends AbstractVideoQueryBuilder {
|
|||
|
||||
const rows = await this.runQuery()
|
||||
|
||||
|
||||
console.log("🍙🍙🍙🍙", rows);
|
||||
|
||||
if (options.include & VideoInclude.FILES) {
|
||||
const videoIds = Array.from(new Set(rows.map(r => r.id)))
|
||||
|
||||
|
@ -57,6 +60,9 @@ export class VideosModelListQueryBuilder extends AbstractVideoQueryBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
let finalRes = this.videoModelBuilder.buildVideosFromRows({ rows, include: options.include })
|
||||
|
||||
console.log("🧀🧀🧀🧀🧀", finalRes);
|
||||
return this.videoModelBuilder.buildVideosFromRows({ rows, include: options.include })
|
||||
}
|
||||
|
||||
|
|
|
@ -431,13 +431,12 @@ export type ForAPIOptions = {
|
|||
}
|
||||
},
|
||||
|
||||
{
|
||||
fields: [ 'shortVideo' ],
|
||||
where: {
|
||||
shortVideo: false
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
fields: [ 'shortVideo' ],
|
||||
where: {
|
||||
shortVideo: false
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
fields: [ 'isLive' ], // Most of the videos are VOD
|
||||
|
@ -1171,9 +1170,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
|||
|
||||
excludeAlreadyWatched?: boolean
|
||||
|
||||
durationMax?:number
|
||||
|
||||
shortVideo? : boolean
|
||||
shortVideo?: boolean
|
||||
}) {
|
||||
VideoModel.throwIfPrivateIncludeWithoutUser(options.include, options.user)
|
||||
VideoModel.throwIfPrivacyOneOfWithoutUser(options.privacyOneOf, options.user)
|
||||
|
@ -1215,7 +1212,6 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
|||
'hasWebVideoFiles',
|
||||
'search',
|
||||
'excludeAlreadyWatched',
|
||||
'durationMax',
|
||||
'shortVideo'
|
||||
]),
|
||||
|
||||
|
@ -1647,6 +1643,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
|||
countVideos = true
|
||||
): Promise<ResultList<VideoModel>> {
|
||||
|
||||
|
||||
const span = tracer.startSpan('peertube.VideoModel.getAvailableForApi')
|
||||
|
||||
function getCount () {
|
||||
|
|
Loading…
Reference in New Issue