]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/transcoding/shared/job-builders/abstract-job-builder.ts
Add TMP persistent directory
[github/Chocobozzz/PeerTube.git] / server / lib / transcoding / shared / job-builders / abstract-job-builder.ts
1
2 import { JOB_PRIORITY } from '@server/initializers/constants'
3 import { VideoModel } from '@server/models/video/video'
4 import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models'
5
6 export abstract class AbstractJobBuilder {
7
8 abstract createOptimizeOrMergeAudioJobs (options: {
9 video: MVideoFullLight
10 videoFile: MVideoFile
11 isNewVideo: boolean
12 user: MUserId
13 videoFileAlreadyLocked: boolean
14 }): Promise<any>
15
16 abstract createTranscodingJobs (options: {
17 transcodingType: 'hls' | 'webtorrent'
18 video: MVideoFullLight
19 resolutions: number[]
20 isNewVideo: boolean
21 user: MUserId | null
22 }): Promise<any>
23
24 protected async getTranscodingJobPriority (options: {
25 user: MUserId
26 fallback: number
27 }) {
28 const { user, fallback } = options
29
30 if (!user) return fallback
31
32 const now = new Date()
33 const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7)
34
35 const videoUploadedByUser = await VideoModel.countVideosUploadedByUserSince(user.id, lastWeek)
36
37 return JOB_PRIORITY.TRANSCODING + videoUploadedByUser
38 }
39 }