]>
Commit | Line | Data |
---|---|---|
92e66e04 | 1 | import { HttpStatusCode, VideoStudioTask } from '@shared/models' |
c729caf6 C |
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
3 | ||
92e66e04 | 4 | export class VideoStudioCommand extends AbstractCommand { |
c729caf6 | 5 | |
92e66e04 | 6 | static getComplexTask (): VideoStudioTask[] { |
c729caf6 C |
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 | |
92e66e04 | 44 | tasks: VideoStudioTask[] |
c729caf6 | 45 | }) { |
92e66e04 | 46 | const path = '/api/v1/videos/' + options.videoId + '/studio/edit' |
c729caf6 C |
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 | } |