]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/server/job.model.ts
Merge branch 'release/4.1.0' into develop
[github/Chocobozzz/PeerTube.git] / shared / models / server / job.model.ts
1 import { ContextType } from '../activitypub/context'
2 import { VideoEditorTaskCut } from '../videos/editor'
3 import { VideoResolution } from '../videos/file/video-resolution.enum'
4 import { SendEmailOptions } from './emailer.model'
5
6 export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused'
7
8 export type JobType =
9 | 'activitypub-http-unicast'
10 | 'activitypub-http-broadcast'
11 | 'activitypub-http-fetcher'
12 | 'activitypub-cleaner'
13 | 'activitypub-follow'
14 | 'video-file-import'
15 | 'video-transcoding'
16 | 'email'
17 | 'video-import'
18 | 'videos-views-stats'
19 | 'activitypub-refresher'
20 | 'video-redundancy'
21 | 'video-live-ending'
22 | 'actor-keys'
23 | 'move-to-object-storage'
24 | 'video-edition'
25
26 export interface Job {
27 id: number
28 state: JobState
29 type: JobType
30 data: any
31 priority: number
32 progress: number
33 error: any
34 createdAt: Date | string
35 finishedOn: Date | string
36 processedOn: Date | string
37 }
38
39 export type ActivitypubHttpBroadcastPayload = {
40 uris: string[]
41 signatureActorId?: number
42 body: any
43 contextType?: ContextType
44 }
45
46 export type ActivitypubFollowPayload = {
47 followerActorId: number
48 name: string
49 host: string
50 isAutoFollow?: boolean
51 assertIsChannel?: boolean
52 }
53
54 export type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 'account-playlists'
55 export type ActivitypubHttpFetcherPayload = {
56 uri: string
57 type: FetchType
58 videoId?: number
59 }
60
61 export type ActivitypubHttpUnicastPayload = {
62 uri: string
63 signatureActorId?: number
64 body: object
65 contextType?: ContextType
66 }
67
68 export type RefreshPayload = {
69 type: 'video' | 'video-playlist' | 'actor'
70 url: string
71 }
72
73 export type EmailPayload = SendEmailOptions
74
75 export type VideoFileImportPayload = {
76 videoUUID: string
77 filePath: string
78 }
79
80 export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file'
81 export type VideoImportYoutubeDLPayloadType = 'youtube-dl'
82
83 export type VideoImportYoutubeDLPayload = {
84 type: VideoImportYoutubeDLPayloadType
85 videoImportId: number
86
87 fileExt?: string
88 }
89 export type VideoImportTorrentPayload = {
90 type: VideoImportTorrentPayloadType
91 videoImportId: number
92 }
93 export type VideoImportPayload = VideoImportYoutubeDLPayload | VideoImportTorrentPayload
94
95 export type VideoRedundancyPayload = {
96 videoId: number
97 }
98
99 // Video transcoding payloads
100
101 interface BaseTranscodingPayload {
102 videoUUID: string
103 isNewVideo?: boolean
104 }
105
106 export interface HLSTranscodingPayload extends BaseTranscodingPayload {
107 type: 'new-resolution-to-hls'
108 resolution: VideoResolution
109 copyCodecs: boolean
110
111 hasAudio: boolean
112 isPortraitMode?: boolean
113
114 autoDeleteWebTorrentIfNeeded: boolean
115 isMaxQuality: boolean
116 }
117
118 export interface NewWebTorrentResolutionTranscodingPayload extends BaseTranscodingPayload {
119 type: 'new-resolution-to-webtorrent'
120 resolution: VideoResolution
121
122 hasAudio: boolean
123 createHLSIfNeeded: boolean
124
125 isPortraitMode?: boolean
126 }
127
128 export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
129 type: 'merge-audio-to-webtorrent'
130 resolution: VideoResolution
131 createHLSIfNeeded: true
132 }
133
134 export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
135 type: 'optimize-to-webtorrent'
136 }
137
138 export type VideoTranscodingPayload =
139 HLSTranscodingPayload
140 | NewWebTorrentResolutionTranscodingPayload
141 | OptimizeTranscodingPayload
142 | MergeAudioTranscodingPayload
143
144 export interface VideoLiveEndingPayload {
145 videoId: number
146 }
147
148 export interface ActorKeysPayload {
149 actorId: number
150 }
151
152 export interface DeleteResumableUploadMetaFilePayload {
153 filepath: string
154 }
155
156 export interface MoveObjectStoragePayload {
157 videoUUID: string
158 isNewVideo: boolean
159 }
160
161 export type VideoEditorTaskCutPayload = VideoEditorTaskCut
162
163 export type VideoEditorTaskIntroPayload = {
164 name: 'add-intro'
165
166 options: {
167 file: string
168 }
169 }
170
171 export type VideoEditorTaskOutroPayload = {
172 name: 'add-outro'
173
174 options: {
175 file: string
176 }
177 }
178
179 export type VideoEditorTaskWatermarkPayload = {
180 name: 'add-watermark'
181
182 options: {
183 file: string
184 }
185 }
186
187 export type VideoEditionTaskPayload =
188 VideoEditorTaskCutPayload |
189 VideoEditorTaskIntroPayload |
190 VideoEditorTaskOutroPayload |
191 VideoEditorTaskWatermarkPayload
192
193 export interface VideoEditionPayload {
194 videoUUID: string
195 tasks: VideoEditionTaskPayload[]
196 }