aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/server-commands
diff options
context:
space:
mode:
Diffstat (limited to 'shared/server-commands')
-rw-r--r--shared/server-commands/server/config-command.ts34
-rw-r--r--shared/server-commands/server/server.ts3
-rw-r--r--shared/server-commands/server/servers-command.ts17
-rw-r--r--shared/server-commands/users/accounts.ts15
-rw-r--r--shared/server-commands/users/index.ts1
-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
8 files changed, 143 insertions, 8 deletions
diff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.ts
index 797231b1d..c0042060b 100644
--- a/shared/server-commands/server/config-command.ts
+++ b/shared/server-commands/server/config-command.ts
@@ -59,6 +59,9 @@ export class ConfigCommand extends AbstractCommand {
59 newConfig: { 59 newConfig: {
60 transcoding: { 60 transcoding: {
61 enabled: false 61 enabled: false
62 },
63 videoEditor: {
64 enabled: false
62 } 65 }
63 } 66 }
64 }) 67 })
@@ -69,6 +72,10 @@ export class ConfigCommand extends AbstractCommand {
69 newConfig: { 72 newConfig: {
70 transcoding: { 73 transcoding: {
71 enabled: true, 74 enabled: true,
75
76 allowAudioFiles: true,
77 allowAdditionalExtensions: true,
78
72 resolutions: ConfigCommand.getCustomConfigResolutions(true), 79 resolutions: ConfigCommand.getCustomConfigResolutions(true),
73 80
74 webtorrent: { 81 webtorrent: {
@@ -82,6 +89,28 @@ export class ConfigCommand extends AbstractCommand {
82 }) 89 })
83 } 90 }
84 91
92 enableMinimumTranscoding (webtorrent = true, hls = true) {
93 return this.updateExistingSubConfig({
94 newConfig: {
95 transcoding: {
96 enabled: true,
97 resolutions: {
98 ...ConfigCommand.getCustomConfigResolutions(false),
99
100 '240p': true
101 },
102
103 webtorrent: {
104 enabled: webtorrent
105 },
106 hls: {
107 enabled: hls
108 }
109 }
110 }
111 })
112 }
113
85 getConfig (options: OverrideCommandOptions = {}) { 114 getConfig (options: OverrideCommandOptions = {}) {
86 const path = '/api/v1/config' 115 const path = '/api/v1/config'
87 116
@@ -148,7 +177,7 @@ export class ConfigCommand extends AbstractCommand {
148 async updateExistingSubConfig (options: OverrideCommandOptions & { 177 async updateExistingSubConfig (options: OverrideCommandOptions & {
149 newConfig: DeepPartial<CustomConfig> 178 newConfig: DeepPartial<CustomConfig>
150 }) { 179 }) {
151 const existing = await this.getCustomConfig(options) 180 const existing = await this.getCustomConfig({ ...options, expectedStatus: HttpStatusCode.OK_200 })
152 181
153 return this.updateCustomConfig({ ...options, newCustomConfig: merge({}, existing, options.newConfig) }) 182 return this.updateCustomConfig({ ...options, newCustomConfig: merge({}, existing, options.newConfig) })
154 } 183 }
@@ -282,6 +311,9 @@ export class ConfigCommand extends AbstractCommand {
282 } 311 }
283 } 312 }
284 }, 313 },
314 videoEditor: {
315 enabled: false
316 },
285 import: { 317 import: {
286 videos: { 318 videos: {
287 concurrency: 3, 319 concurrency: 3,
diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts
index da89fd876..af4423e8d 100644
--- a/shared/server-commands/server/server.ts
+++ b/shared/server-commands/server/server.ts
@@ -25,6 +25,7 @@ import {
25 PlaylistsCommand, 25 PlaylistsCommand,
26 ServicesCommand, 26 ServicesCommand,
27 StreamingPlaylistsCommand, 27 StreamingPlaylistsCommand,
28 VideoEditorCommand,
28 VideosCommand 29 VideosCommand
29} from '../videos' 30} from '../videos'
30import { CommentsCommand } from '../videos/comments-command' 31import { CommentsCommand } from '../videos/comments-command'
@@ -124,6 +125,7 @@ export class PeerTubeServer {
124 login?: LoginCommand 125 login?: LoginCommand
125 users?: UsersCommand 126 users?: UsersCommand
126 objectStorage?: ObjectStorageCommand 127 objectStorage?: ObjectStorageCommand
128 videoEditor?: VideoEditorCommand
127 videos?: VideosCommand 129 videos?: VideosCommand
128 130
129 constructor (options: { serverNumber: number } | { url: string }) { 131 constructor (options: { serverNumber: number } | { url: string }) {
@@ -394,5 +396,6 @@ export class PeerTubeServer {
394 this.users = new UsersCommand(this) 396 this.users = new UsersCommand(this)
395 this.videos = new VideosCommand(this) 397 this.videos = new VideosCommand(this)
396 this.objectStorage = new ObjectStorageCommand(this) 398 this.objectStorage = new ObjectStorageCommand(this)
399 this.videoEditor = new VideoEditorCommand(this)
397 } 400 }
398} 401}
diff --git a/shared/server-commands/server/servers-command.ts b/shared/server-commands/server/servers-command.ts
index c5d8d18dc..19645cb93 100644
--- a/shared/server-commands/server/servers-command.ts
+++ b/shared/server-commands/server/servers-command.ts
@@ -30,10 +30,12 @@ export class ServersCommand extends AbstractCommand {
30 }) 30 })
31 } 31 }
32 32
33 async cleanupTests () { 33 cleanupTests () {
34 const p: Promise<any>[] = [] 34 const promises: Promise<any>[] = []
35
36 const saveGithubLogsIfNeeded = async () => {
37 if (!isGithubCI()) return
35 38
36 if (isGithubCI()) {
37 await ensureDir('artifacts') 39 await ensureDir('artifacts')
38 40
39 const origin = this.buildDirectory('logs/peertube.log') 41 const origin = this.buildDirectory('logs/peertube.log')
@@ -44,14 +46,17 @@ export class ServersCommand extends AbstractCommand {
44 } 46 }
45 47
46 if (this.server.parallel) { 48 if (this.server.parallel) {
47 p.push(ServersCommand.flushTests(this.server.internalServerNumber)) 49 const promise = saveGithubLogsIfNeeded()
50 .then(() => ServersCommand.flushTests(this.server.internalServerNumber))
51
52 promises.push(promise)
48 } 53 }
49 54
50 if (this.server.customConfigFile) { 55 if (this.server.customConfigFile) {
51 p.push(remove(this.server.customConfigFile)) 56 promises.push(remove(this.server.customConfigFile))
52 } 57 }
53 58
54 return p 59 return promises
55 } 60 }
56 61
57 async waitUntilLog (str: string, count = 1, strictCount = true) { 62 async waitUntilLog (str: string, count = 1, strictCount = true) {
diff --git a/shared/server-commands/users/accounts.ts b/shared/server-commands/users/accounts.ts
new file mode 100644
index 000000000..6387891f4
--- /dev/null
+++ b/shared/server-commands/users/accounts.ts
@@ -0,0 +1,15 @@
1import { PeerTubeServer } from '../server/server'
2
3async function setDefaultAccountAvatar (serversArg: PeerTubeServer | PeerTubeServer[], token?: string) {
4 const servers = Array.isArray(serversArg)
5 ? serversArg
6 : [ serversArg ]
7
8 for (const server of servers) {
9 await server.users.updateMyAvatar({ fixture: 'avatar.png', token })
10 }
11}
12
13export {
14 setDefaultAccountAvatar
15}
diff --git a/shared/server-commands/users/index.ts b/shared/server-commands/users/index.ts
index c2bc5c44f..f6f93b4d2 100644
--- a/shared/server-commands/users/index.ts
+++ b/shared/server-commands/users/index.ts
@@ -1,4 +1,5 @@
1export * from './accounts-command' 1export * from './accounts-command'
2export * from './accounts'
2export * from './blocklist-command' 3export * from './blocklist-command'
3export * from './login' 4export * from './login'
4export * from './login-command' 5export * from './login-command'
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}