aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/server-commands/videos
diff options
context:
space:
mode:
Diffstat (limited to 'shared/server-commands/videos')
-rw-r--r--shared/server-commands/videos/channels.ts13
-rw-r--r--shared/server-commands/videos/index.ts1
-rw-r--r--shared/server-commands/videos/video-editor-command.ts67
3 files changed, 80 insertions, 1 deletions
diff --git a/shared/server-commands/videos/channels.ts b/shared/server-commands/videos/channels.ts
index 756c47453..3c0d4b723 100644
--- a/shared/server-commands/videos/channels.ts
+++ b/shared/server-commands/videos/channels.ts
@@ -13,6 +13,17 @@ function setDefaultVideoChannel (servers: PeerTubeServer[]) {
13 return Promise.all(tasks) 13 return Promise.all(tasks)
14} 14}
15 15
16async function setDefaultChannelAvatar (serversArg: PeerTubeServer | PeerTubeServer[], channelName: string = 'root_channel') {
17 const servers = Array.isArray(serversArg)
18 ? serversArg
19 : [ serversArg ]
20
21 for (const server of servers) {
22 await server.channels.updateImage({ channelName, fixture: 'avatar.png', type: 'avatar' })
23 }
24}
25
16export { 26export {
17 setDefaultVideoChannel 27 setDefaultVideoChannel,
28 setDefaultChannelAvatar
18} 29}
diff --git a/shared/server-commands/videos/index.ts b/shared/server-commands/videos/index.ts
index 68a188b21..154aed9a6 100644
--- a/shared/server-commands/videos/index.ts
+++ b/shared/server-commands/videos/index.ts
@@ -12,4 +12,5 @@ export * from './playlists-command'
12export * from './services-command' 12export * from './services-command'
13export * from './streaming-playlists-command' 13export * from './streaming-playlists-command'
14export * from './comments-command' 14export * from './comments-command'
15export * from './video-editor-command'
15export * from './videos-command' 16export * from './videos-command'
diff --git a/shared/server-commands/videos/video-editor-command.ts b/shared/server-commands/videos/video-editor-command.ts
new file mode 100644
index 000000000..485edce8e
--- /dev/null
+++ b/shared/server-commands/videos/video-editor-command.ts
@@ -0,0 +1,67 @@
1import { HttpStatusCode, VideoEditorTask } from '@shared/models'
2import { AbstractCommand, OverrideCommandOptions } from '../shared'
3
4export class VideoEditorCommand extends AbstractCommand {
5
6 static getComplexTask (): VideoEditorTask[] {
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: VideoEditorTask[]
45 }) {
46 const path = '/api/v1/videos/' + options.videoId + '/editor/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}