]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/server/job.model.ts
Add peertube runner cli
[github/Chocobozzz/PeerTube.git] / shared / models / server / job.model.ts
1 import { ContextType } from '../activitypub/context'
2 import { VideoState } from '../videos'
3 import { VideoResolution } from '../videos/file/video-resolution.enum'
4 import { VideoStudioTaskCut } from '../videos/studio'
5 import { SendEmailOptions } from './emailer.model'
6
7 export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused' | 'waiting-children'
8
9 export type JobType =
10 | 'activitypub-cleaner'
11 | 'activitypub-follow'
12 | 'activitypub-http-broadcast-parallel'
13 | 'activitypub-http-broadcast'
14 | 'activitypub-http-fetcher'
15 | 'activitypub-http-unicast'
16 | 'activitypub-refresher'
17 | 'actor-keys'
18 | 'after-video-channel-import'
19 | 'email'
20 | 'federate-video'
21 | 'transcoding-job-builder'
22 | 'manage-video-torrent'
23 | 'move-to-object-storage'
24 | 'notify'
25 | 'video-channel-import'
26 | 'video-file-import'
27 | 'video-import'
28 | 'video-live-ending'
29 | 'video-redundancy'
30 | 'video-studio-edition'
31 | 'video-transcoding'
32 | 'videos-views-stats'
33
34 export interface Job {
35 id: number | string
36 state: JobState | 'unknown'
37 type: JobType
38 data: any
39 priority: number
40 progress: number
41 error: any
42 createdAt: Date | string
43 finishedOn: Date | string
44 processedOn: Date | string
45
46 parent?: {
47 id: string
48 }
49 }
50
51 export type ActivitypubHttpBroadcastPayload = {
52 uris: string[]
53 contextType: ContextType
54 body: any
55 signatureActorId?: number
56 }
57
58 export type ActivitypubFollowPayload = {
59 followerActorId: number
60 name: string
61 host: string
62 isAutoFollow?: boolean
63 assertIsChannel?: boolean
64 }
65
66 export type FetchType = 'activity' | 'video-shares' | 'video-comments' | 'account-playlists'
67 export type ActivitypubHttpFetcherPayload = {
68 uri: string
69 type: FetchType
70 videoId?: number
71 }
72
73 export type ActivitypubHttpUnicastPayload = {
74 uri: string
75 contextType: ContextType
76 signatureActorId?: number
77 body: object
78 }
79
80 export type RefreshPayload = {
81 type: 'video' | 'video-playlist' | 'actor'
82 url: string
83 }
84
85 export type EmailPayload = SendEmailOptions
86
87 export type VideoFileImportPayload = {
88 videoUUID: string
89 filePath: string
90 }
91
92 // ---------------------------------------------------------------------------
93
94 export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file'
95 export type VideoImportYoutubeDLPayloadType = 'youtube-dl'
96
97 export interface VideoImportYoutubeDLPayload {
98 type: VideoImportYoutubeDLPayloadType
99 videoImportId: number
100
101 fileExt?: string
102 }
103
104 export interface VideoImportTorrentPayload {
105 type: VideoImportTorrentPayloadType
106 videoImportId: number
107 }
108
109 export type VideoImportPayload = (VideoImportYoutubeDLPayload | VideoImportTorrentPayload) & {
110 preventException: boolean
111 }
112
113 export interface VideoImportPreventExceptionResult {
114 resultType: 'success' | 'error'
115 }
116
117 // ---------------------------------------------------------------------------
118
119 export type VideoRedundancyPayload = {
120 videoId: number
121 }
122
123 export type ManageVideoTorrentPayload =
124 {
125 action: 'create'
126 videoId: number
127 videoFileId: number
128 } | {
129 action: 'update-metadata'
130
131 videoId?: number
132 streamingPlaylistId?: number
133
134 videoFileId: number
135 }
136
137 // Video transcoding payloads
138
139 interface BaseTranscodingPayload {
140 videoUUID: string
141 isNewVideo?: boolean
142 }
143
144 export interface HLSTranscodingPayload extends BaseTranscodingPayload {
145 type: 'new-resolution-to-hls'
146 resolution: VideoResolution
147 fps: number
148 copyCodecs: boolean
149
150 deleteWebTorrentFiles: boolean
151 }
152
153 export interface NewWebTorrentResolutionTranscodingPayload extends BaseTranscodingPayload {
154 type: 'new-resolution-to-webtorrent'
155 resolution: VideoResolution
156 fps: number
157 }
158
159 export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
160 type: 'merge-audio-to-webtorrent'
161 resolution: VideoResolution
162 fps: number
163 }
164
165 export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
166 type: 'optimize-to-webtorrent'
167
168 quickTranscode: boolean
169 }
170
171 export type VideoTranscodingPayload =
172 HLSTranscodingPayload
173 | NewWebTorrentResolutionTranscodingPayload
174 | OptimizeTranscodingPayload
175 | MergeAudioTranscodingPayload
176
177 export interface VideoLiveEndingPayload {
178 videoId: number
179 publishedAt: string
180 liveSessionId: number
181 streamingPlaylistId: number
182
183 replayDirectory?: string
184 }
185
186 export interface ActorKeysPayload {
187 actorId: number
188 }
189
190 export interface DeleteResumableUploadMetaFilePayload {
191 filepath: string
192 }
193
194 export interface MoveObjectStoragePayload {
195 videoUUID: string
196 isNewVideo: boolean
197 previousVideoState: VideoState
198 }
199
200 export type VideoStudioTaskCutPayload = VideoStudioTaskCut
201
202 export type VideoStudioTaskIntroPayload = {
203 name: 'add-intro'
204
205 options: {
206 file: string
207 }
208 }
209
210 export type VideoStudioTaskOutroPayload = {
211 name: 'add-outro'
212
213 options: {
214 file: string
215 }
216 }
217
218 export type VideoStudioTaskWatermarkPayload = {
219 name: 'add-watermark'
220
221 options: {
222 file: string
223 }
224 }
225
226 export type VideoStudioTaskPayload =
227 VideoStudioTaskCutPayload |
228 VideoStudioTaskIntroPayload |
229 VideoStudioTaskOutroPayload |
230 VideoStudioTaskWatermarkPayload
231
232 export interface VideoStudioEditionPayload {
233 videoUUID: string
234 tasks: VideoStudioTaskPayload[]
235 }
236
237 // ---------------------------------------------------------------------------
238
239 export interface VideoChannelImportPayload {
240 externalChannelUrl: string
241 videoChannelId: number
242
243 partOfChannelSyncId?: number
244 }
245
246 export interface AfterVideoChannelImportPayload {
247 channelSyncId: number
248 }
249
250 // ---------------------------------------------------------------------------
251
252 export type NotifyPayload =
253 {
254 action: 'new-video'
255 videoUUID: string
256 }
257
258 // ---------------------------------------------------------------------------
259
260 export interface FederateVideoPayload {
261 videoUUID: string
262 isNewVideo: boolean
263 }
264
265 // ---------------------------------------------------------------------------
266
267 export interface TranscodingJobBuilderPayload {
268 videoUUID: string
269
270 optimizeJob?: {
271 isNewVideo: boolean
272 }
273
274 // Array of jobs to create
275 jobs?: {
276 type: 'video-transcoding'
277 payload: VideoTranscodingPayload
278 priority?: number
279 }[]
280
281 // Array of sequential jobs to create
282 sequentialJobs?: {
283 type: 'video-transcoding'
284 payload: VideoTranscodingPayload
285 priority?: number
286 }[][]
287 }