aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/server-commands/videos/video-studio-command.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/server-commands/videos/video-studio-command.ts')
-rw-r--r--shared/server-commands/videos/video-studio-command.ts67
1 files changed, 67 insertions, 0 deletions
diff --git a/shared/server-commands/videos/video-studio-command.ts b/shared/server-commands/videos/video-studio-command.ts
new file mode 100644
index 000000000..9fe467cc2
--- /dev/null
+++ b/shared/server-commands/videos/video-studio-command.ts
@@ -0,0 +1,67 @@
1import { HttpStatusCode, VideoStudioTask } from '@shared/models'
2import { AbstractCommand, OverrideCommandOptions } from '../shared'
3
4export class VideoStudioCommand extends AbstractCommand {
5
6 static getComplexTask (): VideoStudioTask[] {
7 return [
8 // Total duration: 2
9 {
10 name: 'cut',
11 options: {
12 start: 1,
13 end: 3
14 }
15 },
16
17 // Total duration: 7
18 {
19 name: 'add-outro',
20 options: {
21 file: 'video_short.webm'
22 }
23 },
24
25 {
26 name: 'add-watermark',
27 options: {
28 file: 'thumbnail.png'
29 }
30 },
31
32 // Total duration: 9
33 {
34 name: 'add-intro',
35 options: {
36 file: 'video_very_short_240p.mp4'
37 }
38 }
39 ]
40 }
41
42 createEditionTasks (options: OverrideCommandOptions & {
43 videoId: number | string
44 tasks: VideoStudioTask[]
45 }) {
46 const path = '/api/v1/videos/' + options.videoId + '/studio/edit'
47 const attaches: { [id: string]: any } = {}
48
49 for (let i = 0; i < options.tasks.length; i++) {
50 const task = options.tasks[i]
51
52 if (task.name === 'add-intro' || task.name === 'add-outro' || task.name === 'add-watermark') {
53 attaches[`tasks[${i}][options][file]`] = task.options.file
54 }
55 }
56
57 return this.postUploadRequest({
58 ...options,
59
60 path,
61 attaches,
62 fields: { tasks: options.tasks },
63 implicitToken: true,
64 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
65 })
66 }
67}