diff options
Diffstat (limited to 'shared/server-commands')
-rw-r--r-- | shared/server-commands/requests/requests.ts | 4 | ||||
-rw-r--r-- | shared/server-commands/server/config-command.ts | 21 | ||||
-rw-r--r-- | shared/server-commands/server/jobs.ts | 15 | ||||
-rw-r--r-- | shared/server-commands/server/object-storage-command.ts | 6 | ||||
-rw-r--r-- | shared/server-commands/server/server.ts | 13 | ||||
-rw-r--r-- | shared/server-commands/server/servers-command.ts | 4 | ||||
-rw-r--r-- | shared/server-commands/shared/abstract-command.ts | 18 | ||||
-rw-r--r-- | shared/server-commands/videos/captions-command.ts | 4 | ||||
-rw-r--r-- | shared/server-commands/videos/comments-command.ts | 12 | ||||
-rw-r--r-- | shared/server-commands/videos/index.ts | 2 | ||||
-rw-r--r-- | shared/server-commands/videos/live-command.ts | 12 | ||||
-rw-r--r-- | shared/server-commands/videos/storyboard-command.ts | 19 | ||||
-rw-r--r-- | shared/server-commands/videos/video-passwords-command.ts | 55 | ||||
-rw-r--r-- | shared/server-commands/videos/video-studio-command.ts | 2 | ||||
-rw-r--r-- | shared/server-commands/videos/video-token-command.ts | 5 | ||||
-rw-r--r-- | shared/server-commands/videos/videos-command.ts | 33 |
16 files changed, 190 insertions, 35 deletions
diff --git a/shared/server-commands/requests/requests.ts b/shared/server-commands/requests/requests.ts index e3f1817f1..8227017eb 100644 --- a/shared/server-commands/requests/requests.ts +++ b/shared/server-commands/requests/requests.ts | |||
@@ -29,6 +29,7 @@ function makeRawRequest (options: { | |||
29 | range?: string | 29 | range?: string |
30 | query?: { [ id: string ]: string } | 30 | query?: { [ id: string ]: string } |
31 | method?: 'GET' | 'POST' | 31 | method?: 'GET' | 'POST' |
32 | headers?: { [ name: string ]: string } | ||
32 | }) { | 33 | }) { |
33 | const { host, protocol, pathname } = new URL(options.url) | 34 | const { host, protocol, pathname } = new URL(options.url) |
34 | 35 | ||
@@ -37,7 +38,7 @@ function makeRawRequest (options: { | |||
37 | path: pathname, | 38 | path: pathname, |
38 | contentType: undefined, | 39 | contentType: undefined, |
39 | 40 | ||
40 | ...pick(options, [ 'expectedStatus', 'range', 'token', 'query' ]) | 41 | ...pick(options, [ 'expectedStatus', 'range', 'token', 'query', 'headers' ]) |
41 | } | 42 | } |
42 | 43 | ||
43 | if (options.method === 'POST') { | 44 | if (options.method === 'POST') { |
@@ -132,6 +133,7 @@ function makePutBodyRequest (options: { | |||
132 | token?: string | 133 | token?: string |
133 | fields: { [ fieldName: string ]: any } | 134 | fields: { [ fieldName: string ]: any } |
134 | expectedStatus?: HttpStatusCode | 135 | expectedStatus?: HttpStatusCode |
136 | headers?: { [name: string]: string } | ||
135 | }) { | 137 | }) { |
136 | const req = request(options.url).put(options.path) | 138 | const req = request(options.url).put(options.path) |
137 | .send(options.fields) | 139 | .send(options.fields) |
diff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.ts index b94bd2625..7f1e9d977 100644 --- a/shared/server-commands/server/config-command.ts +++ b/shared/server-commands/server/config-command.ts | |||
@@ -131,7 +131,7 @@ export class ConfigCommand extends AbstractCommand { | |||
131 | } | 131 | } |
132 | 132 | ||
133 | // TODO: convert args to object | 133 | // TODO: convert args to object |
134 | enableTranscoding (webtorrent = true, hls = true, with0p = false) { | 134 | enableTranscoding (webVideo = true, hls = true, with0p = false) { |
135 | return this.updateExistingSubConfig({ | 135 | return this.updateExistingSubConfig({ |
136 | newConfig: { | 136 | newConfig: { |
137 | transcoding: { | 137 | transcoding: { |
@@ -142,8 +142,8 @@ export class ConfigCommand extends AbstractCommand { | |||
142 | 142 | ||
143 | resolutions: ConfigCommand.getCustomConfigResolutions(true, with0p), | 143 | resolutions: ConfigCommand.getCustomConfigResolutions(true, with0p), |
144 | 144 | ||
145 | webtorrent: { | 145 | webVideos: { |
146 | enabled: webtorrent | 146 | enabled: webVideo |
147 | }, | 147 | }, |
148 | hls: { | 148 | hls: { |
149 | enabled: hls | 149 | enabled: hls |
@@ -154,19 +154,23 @@ export class ConfigCommand extends AbstractCommand { | |||
154 | } | 154 | } |
155 | 155 | ||
156 | // TODO: convert args to object | 156 | // TODO: convert args to object |
157 | enableMinimumTranscoding (webtorrent = true, hls = true) { | 157 | enableMinimumTranscoding (webVideo = true, hls = true) { |
158 | return this.updateExistingSubConfig({ | 158 | return this.updateExistingSubConfig({ |
159 | newConfig: { | 159 | newConfig: { |
160 | transcoding: { | 160 | transcoding: { |
161 | enabled: true, | 161 | enabled: true, |
162 | |||
163 | allowAudioFiles: true, | ||
164 | allowAdditionalExtensions: true, | ||
165 | |||
162 | resolutions: { | 166 | resolutions: { |
163 | ...ConfigCommand.getCustomConfigResolutions(false), | 167 | ...ConfigCommand.getCustomConfigResolutions(false), |
164 | 168 | ||
165 | '240p': true | 169 | '240p': true |
166 | }, | 170 | }, |
167 | 171 | ||
168 | webtorrent: { | 172 | webVideos: { |
169 | enabled: webtorrent | 173 | enabled: webVideo |
170 | }, | 174 | }, |
171 | hls: { | 175 | hls: { |
172 | enabled: hls | 176 | enabled: hls |
@@ -368,6 +372,9 @@ export class ConfigCommand extends AbstractCommand { | |||
368 | }, | 372 | }, |
369 | torrents: { | 373 | torrents: { |
370 | size: 4 | 374 | size: 4 |
375 | }, | ||
376 | storyboards: { | ||
377 | size: 5 | ||
371 | } | 378 | } |
372 | }, | 379 | }, |
373 | signup: { | 380 | signup: { |
@@ -417,7 +424,7 @@ export class ConfigCommand extends AbstractCommand { | |||
417 | '2160p': false | 424 | '2160p': false |
418 | }, | 425 | }, |
419 | alwaysTranscodeOriginalResolution: true, | 426 | alwaysTranscodeOriginalResolution: true, |
420 | webtorrent: { | 427 | webVideos: { |
421 | enabled: true | 428 | enabled: true |
422 | }, | 429 | }, |
423 | hls: { | 430 | hls: { |
diff --git a/shared/server-commands/server/jobs.ts b/shared/server-commands/server/jobs.ts index ff3098063..8f131fba4 100644 --- a/shared/server-commands/server/jobs.ts +++ b/shared/server-commands/server/jobs.ts | |||
@@ -33,6 +33,8 @@ async function waitJobs ( | |||
33 | 33 | ||
34 | // Check if each server has pending request | 34 | // Check if each server has pending request |
35 | for (const server of servers) { | 35 | for (const server of servers) { |
36 | if (process.env.DEBUG) console.log('Checking ' + server.url) | ||
37 | |||
36 | for (const state of states) { | 38 | for (const state of states) { |
37 | 39 | ||
38 | const jobPromise = server.jobs.list({ | 40 | const jobPromise = server.jobs.list({ |
@@ -45,6 +47,10 @@ async function waitJobs ( | |||
45 | .then(jobs => { | 47 | .then(jobs => { |
46 | if (jobs.length !== 0) { | 48 | if (jobs.length !== 0) { |
47 | pendingRequests = true | 49 | pendingRequests = true |
50 | |||
51 | if (process.env.DEBUG) { | ||
52 | console.log(jobs) | ||
53 | } | ||
48 | } | 54 | } |
49 | }) | 55 | }) |
50 | 56 | ||
@@ -55,6 +61,10 @@ async function waitJobs ( | |||
55 | .then(obj => { | 61 | .then(obj => { |
56 | if (obj.activityPubMessagesWaiting !== 0) { | 62 | if (obj.activityPubMessagesWaiting !== 0) { |
57 | pendingRequests = true | 63 | pendingRequests = true |
64 | |||
65 | if (process.env.DEBUG) { | ||
66 | console.log('AP messages waiting: ' + obj.activityPubMessagesWaiting) | ||
67 | } | ||
58 | } | 68 | } |
59 | }) | 69 | }) |
60 | tasks.push(debugPromise) | 70 | tasks.push(debugPromise) |
@@ -65,12 +75,15 @@ async function waitJobs ( | |||
65 | for (const job of data) { | 75 | for (const job of data) { |
66 | if (job.state.id !== RunnerJobState.COMPLETED) { | 76 | if (job.state.id !== RunnerJobState.COMPLETED) { |
67 | pendingRequests = true | 77 | pendingRequests = true |
78 | |||
79 | if (process.env.DEBUG) { | ||
80 | console.log(job) | ||
81 | } | ||
68 | } | 82 | } |
69 | } | 83 | } |
70 | }) | 84 | }) |
71 | tasks.push(runnerJobsPromise) | 85 | tasks.push(runnerJobsPromise) |
72 | } | 86 | } |
73 | |||
74 | } | 87 | } |
75 | 88 | ||
76 | return tasks | 89 | return tasks |
diff --git a/shared/server-commands/server/object-storage-command.ts b/shared/server-commands/server/object-storage-command.ts index 7d8ec93cd..6bb232c36 100644 --- a/shared/server-commands/server/object-storage-command.ts +++ b/shared/server-commands/server/object-storage-command.ts | |||
@@ -42,7 +42,7 @@ export class ObjectStorageCommand { | |||
42 | bucket_name: this.getMockStreamingPlaylistsBucketName() | 42 | bucket_name: this.getMockStreamingPlaylistsBucketName() |
43 | }, | 43 | }, |
44 | 44 | ||
45 | videos: { | 45 | web_videos: { |
46 | bucket_name: this.getMockWebVideosBucketName() | 46 | bucket_name: this.getMockWebVideosBucketName() |
47 | } | 47 | } |
48 | } | 48 | } |
@@ -136,9 +136,9 @@ export class ObjectStorageCommand { | |||
136 | prefix: `test:server-${serverNumber}-streaming-playlists:` | 136 | prefix: `test:server-${serverNumber}-streaming-playlists:` |
137 | }, | 137 | }, |
138 | 138 | ||
139 | videos: { | 139 | web_videos: { |
140 | bucket_name: this.DEFAULT_SCALEWAY_BUCKET, | 140 | bucket_name: this.DEFAULT_SCALEWAY_BUCKET, |
141 | prefix: `test:server-${serverNumber}-videos:` | 141 | prefix: `test:server-${serverNumber}-web-videos:` |
142 | } | 142 | } |
143 | } | 143 | } |
144 | } | 144 | } |
diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts index 70f7a3ee2..38568a890 100644 --- a/shared/server-commands/server/server.ts +++ b/shared/server-commands/server/server.ts | |||
@@ -32,8 +32,10 @@ import { | |||
32 | HistoryCommand, | 32 | HistoryCommand, |
33 | ImportsCommand, | 33 | ImportsCommand, |
34 | LiveCommand, | 34 | LiveCommand, |
35 | VideoPasswordsCommand, | ||
35 | PlaylistsCommand, | 36 | PlaylistsCommand, |
36 | ServicesCommand, | 37 | ServicesCommand, |
38 | StoryboardCommand, | ||
37 | StreamingPlaylistsCommand, | 39 | StreamingPlaylistsCommand, |
38 | VideosCommand, | 40 | VideosCommand, |
39 | VideoStudioCommand, | 41 | VideoStudioCommand, |
@@ -146,6 +148,9 @@ export class PeerTubeServer { | |||
146 | twoFactor?: TwoFactorCommand | 148 | twoFactor?: TwoFactorCommand |
147 | videoToken?: VideoTokenCommand | 149 | videoToken?: VideoTokenCommand |
148 | registrations?: RegistrationsCommand | 150 | registrations?: RegistrationsCommand |
151 | videoPasswords?: VideoPasswordsCommand | ||
152 | |||
153 | storyboard?: StoryboardCommand | ||
149 | 154 | ||
150 | runners?: RunnersCommand | 155 | runners?: RunnersCommand |
151 | runnerRegistrationTokens?: RunnerRegistrationTokensCommand | 156 | runnerRegistrationTokens?: RunnerRegistrationTokensCommand |
@@ -232,7 +237,7 @@ export class PeerTubeServer { | |||
232 | } | 237 | } |
233 | 238 | ||
234 | // Share the environment | 239 | // Share the environment |
235 | const env = Object.create(process.env) | 240 | const env = { ...process.env } |
236 | env['NODE_ENV'] = 'test' | 241 | env['NODE_ENV'] = 'test' |
237 | env['NODE_APP_INSTANCE'] = this.internalServerNumber.toString() | 242 | env['NODE_APP_INSTANCE'] = this.internalServerNumber.toString() |
238 | env['NODE_CONFIG'] = JSON.stringify(configOverride) | 243 | env['NODE_CONFIG'] = JSON.stringify(configOverride) |
@@ -365,12 +370,13 @@ export class PeerTubeServer { | |||
365 | tmp_persistent: this.getDirectoryPath('tmp-persistent') + '/', | 370 | tmp_persistent: this.getDirectoryPath('tmp-persistent') + '/', |
366 | bin: this.getDirectoryPath('bin') + '/', | 371 | bin: this.getDirectoryPath('bin') + '/', |
367 | avatars: this.getDirectoryPath('avatars') + '/', | 372 | avatars: this.getDirectoryPath('avatars') + '/', |
368 | videos: this.getDirectoryPath('videos') + '/', | 373 | web_videos: this.getDirectoryPath('web-videos') + '/', |
369 | streaming_playlists: this.getDirectoryPath('streaming-playlists') + '/', | 374 | streaming_playlists: this.getDirectoryPath('streaming-playlists') + '/', |
370 | redundancy: this.getDirectoryPath('redundancy') + '/', | 375 | redundancy: this.getDirectoryPath('redundancy') + '/', |
371 | logs: this.getDirectoryPath('logs') + '/', | 376 | logs: this.getDirectoryPath('logs') + '/', |
372 | previews: this.getDirectoryPath('previews') + '/', | 377 | previews: this.getDirectoryPath('previews') + '/', |
373 | thumbnails: this.getDirectoryPath('thumbnails') + '/', | 378 | thumbnails: this.getDirectoryPath('thumbnails') + '/', |
379 | storyboards: this.getDirectoryPath('storyboards') + '/', | ||
374 | torrents: this.getDirectoryPath('torrents') + '/', | 380 | torrents: this.getDirectoryPath('torrents') + '/', |
375 | captions: this.getDirectoryPath('captions') + '/', | 381 | captions: this.getDirectoryPath('captions') + '/', |
376 | cache: this.getDirectoryPath('cache') + '/', | 382 | cache: this.getDirectoryPath('cache') + '/', |
@@ -434,8 +440,11 @@ export class PeerTubeServer { | |||
434 | this.videoToken = new VideoTokenCommand(this) | 440 | this.videoToken = new VideoTokenCommand(this) |
435 | this.registrations = new RegistrationsCommand(this) | 441 | this.registrations = new RegistrationsCommand(this) |
436 | 442 | ||
443 | this.storyboard = new StoryboardCommand(this) | ||
444 | |||
437 | this.runners = new RunnersCommand(this) | 445 | this.runners = new RunnersCommand(this) |
438 | this.runnerRegistrationTokens = new RunnerRegistrationTokensCommand(this) | 446 | this.runnerRegistrationTokens = new RunnerRegistrationTokensCommand(this) |
439 | this.runnerJobs = new RunnerJobsCommand(this) | 447 | this.runnerJobs = new RunnerJobsCommand(this) |
448 | this.videoPasswords = new VideoPasswordsCommand(this) | ||
440 | } | 449 | } |
441 | } | 450 | } |
diff --git a/shared/server-commands/server/servers-command.ts b/shared/server-commands/server/servers-command.ts index 19645cb93..c91c2b008 100644 --- a/shared/server-commands/server/servers-command.ts +++ b/shared/server-commands/server/servers-command.ts | |||
@@ -77,8 +77,8 @@ export class ServersCommand extends AbstractCommand { | |||
77 | return join(root(), 'test' + this.server.internalServerNumber, directory) | 77 | return join(root(), 'test' + this.server.internalServerNumber, directory) |
78 | } | 78 | } |
79 | 79 | ||
80 | buildWebTorrentFilePath (fileUrl: string) { | 80 | buildWebVideoFilePath (fileUrl: string) { |
81 | return this.buildDirectory(join('videos', basename(fileUrl))) | 81 | return this.buildDirectory(join('web-videos', basename(fileUrl))) |
82 | } | 82 | } |
83 | 83 | ||
84 | buildFragmentedFilePath (videoUUID: string, fileUrl: string) { | 84 | buildFragmentedFilePath (videoUUID: string, fileUrl: string) { |
diff --git a/shared/server-commands/shared/abstract-command.ts b/shared/server-commands/shared/abstract-command.ts index ca4ffada9..463acc26b 100644 --- a/shared/server-commands/shared/abstract-command.ts +++ b/shared/server-commands/shared/abstract-command.ts | |||
@@ -101,25 +101,29 @@ abstract class AbstractCommand { | |||
101 | 101 | ||
102 | protected putBodyRequest (options: InternalCommonCommandOptions & { | 102 | protected putBodyRequest (options: InternalCommonCommandOptions & { |
103 | fields?: { [ fieldName: string ]: any } | 103 | fields?: { [ fieldName: string ]: any } |
104 | headers?: { [name: string]: string } | ||
104 | }) { | 105 | }) { |
105 | const { fields } = options | 106 | const { fields, headers } = options |
106 | 107 | ||
107 | return makePutBodyRequest({ | 108 | return makePutBodyRequest({ |
108 | ...this.buildCommonRequestOptions(options), | 109 | ...this.buildCommonRequestOptions(options), |
109 | 110 | ||
110 | fields | 111 | fields, |
112 | headers | ||
111 | }) | 113 | }) |
112 | } | 114 | } |
113 | 115 | ||
114 | protected postBodyRequest (options: InternalCommonCommandOptions & { | 116 | protected postBodyRequest (options: InternalCommonCommandOptions & { |
115 | fields?: { [ fieldName: string ]: any } | 117 | fields?: { [ fieldName: string ]: any } |
118 | headers?: { [name: string]: string } | ||
116 | }) { | 119 | }) { |
117 | const { fields } = options | 120 | const { fields, headers } = options |
118 | 121 | ||
119 | return makePostBodyRequest({ | 122 | return makePostBodyRequest({ |
120 | ...this.buildCommonRequestOptions(options), | 123 | ...this.buildCommonRequestOptions(options), |
121 | 124 | ||
122 | fields | 125 | fields, |
126 | headers | ||
123 | }) | 127 | }) |
124 | } | 128 | } |
125 | 129 | ||
@@ -206,6 +210,12 @@ abstract class AbstractCommand { | |||
206 | 210 | ||
207 | return expectedStatus !== undefined ? expectedStatus : defaultExpectedStatus | 211 | return expectedStatus !== undefined ? expectedStatus : defaultExpectedStatus |
208 | } | 212 | } |
213 | |||
214 | protected buildVideoPasswordHeader (videoPassword: string) { | ||
215 | return videoPassword !== undefined && videoPassword !== null | ||
216 | ? { 'x-peertube-video-password': videoPassword } | ||
217 | : undefined | ||
218 | } | ||
209 | } | 219 | } |
210 | 220 | ||
211 | export { | 221 | export { |
diff --git a/shared/server-commands/videos/captions-command.ts b/shared/server-commands/videos/captions-command.ts index 62bf9c5e6..a26fcb57d 100644 --- a/shared/server-commands/videos/captions-command.ts +++ b/shared/server-commands/videos/captions-command.ts | |||
@@ -34,14 +34,16 @@ export class CaptionsCommand extends AbstractCommand { | |||
34 | 34 | ||
35 | list (options: OverrideCommandOptions & { | 35 | list (options: OverrideCommandOptions & { |
36 | videoId: string | number | 36 | videoId: string | number |
37 | videoPassword?: string | ||
37 | }) { | 38 | }) { |
38 | const { videoId } = options | 39 | const { videoId, videoPassword } = options |
39 | const path = '/api/v1/videos/' + videoId + '/captions' | 40 | const path = '/api/v1/videos/' + videoId + '/captions' |
40 | 41 | ||
41 | return this.getRequestBody<ResultList<VideoCaption>>({ | 42 | return this.getRequestBody<ResultList<VideoCaption>>({ |
42 | ...options, | 43 | ...options, |
43 | 44 | ||
44 | path, | 45 | path, |
46 | headers: this.buildVideoPasswordHeader(videoPassword), | ||
45 | implicitToken: false, | 47 | implicitToken: false, |
46 | defaultExpectedStatus: HttpStatusCode.OK_200 | 48 | defaultExpectedStatus: HttpStatusCode.OK_200 |
47 | }) | 49 | }) |
diff --git a/shared/server-commands/videos/comments-command.ts b/shared/server-commands/videos/comments-command.ts index 154ec0c24..0dab1b66a 100644 --- a/shared/server-commands/videos/comments-command.ts +++ b/shared/server-commands/videos/comments-command.ts | |||
@@ -36,11 +36,12 @@ export class CommentsCommand extends AbstractCommand { | |||
36 | 36 | ||
37 | listThreads (options: OverrideCommandOptions & { | 37 | listThreads (options: OverrideCommandOptions & { |
38 | videoId: number | string | 38 | videoId: number | string |
39 | videoPassword?: string | ||
39 | start?: number | 40 | start?: number |
40 | count?: number | 41 | count?: number |
41 | sort?: string | 42 | sort?: string |
42 | }) { | 43 | }) { |
43 | const { start, count, sort, videoId } = options | 44 | const { start, count, sort, videoId, videoPassword } = options |
44 | const path = '/api/v1/videos/' + videoId + '/comment-threads' | 45 | const path = '/api/v1/videos/' + videoId + '/comment-threads' |
45 | 46 | ||
46 | return this.getRequestBody<VideoCommentThreads>({ | 47 | return this.getRequestBody<VideoCommentThreads>({ |
@@ -48,6 +49,7 @@ export class CommentsCommand extends AbstractCommand { | |||
48 | 49 | ||
49 | path, | 50 | path, |
50 | query: { start, count, sort }, | 51 | query: { start, count, sort }, |
52 | headers: this.buildVideoPasswordHeader(videoPassword), | ||
51 | implicitToken: false, | 53 | implicitToken: false, |
52 | defaultExpectedStatus: HttpStatusCode.OK_200 | 54 | defaultExpectedStatus: HttpStatusCode.OK_200 |
53 | }) | 55 | }) |
@@ -72,8 +74,9 @@ export class CommentsCommand extends AbstractCommand { | |||
72 | async createThread (options: OverrideCommandOptions & { | 74 | async createThread (options: OverrideCommandOptions & { |
73 | videoId: number | string | 75 | videoId: number | string |
74 | text: string | 76 | text: string |
77 | videoPassword?: string | ||
75 | }) { | 78 | }) { |
76 | const { videoId, text } = options | 79 | const { videoId, text, videoPassword } = options |
77 | const path = '/api/v1/videos/' + videoId + '/comment-threads' | 80 | const path = '/api/v1/videos/' + videoId + '/comment-threads' |
78 | 81 | ||
79 | const body = await unwrapBody<{ comment: VideoComment }>(this.postBodyRequest({ | 82 | const body = await unwrapBody<{ comment: VideoComment }>(this.postBodyRequest({ |
@@ -81,6 +84,7 @@ export class CommentsCommand extends AbstractCommand { | |||
81 | 84 | ||
82 | path, | 85 | path, |
83 | fields: { text }, | 86 | fields: { text }, |
87 | headers: this.buildVideoPasswordHeader(videoPassword), | ||
84 | implicitToken: true, | 88 | implicitToken: true, |
85 | defaultExpectedStatus: HttpStatusCode.OK_200 | 89 | defaultExpectedStatus: HttpStatusCode.OK_200 |
86 | })) | 90 | })) |
@@ -95,8 +99,9 @@ export class CommentsCommand extends AbstractCommand { | |||
95 | videoId: number | string | 99 | videoId: number | string |
96 | toCommentId: number | 100 | toCommentId: number |
97 | text: string | 101 | text: string |
102 | videoPassword?: string | ||
98 | }) { | 103 | }) { |
99 | const { videoId, toCommentId, text } = options | 104 | const { videoId, toCommentId, text, videoPassword } = options |
100 | const path = '/api/v1/videos/' + videoId + '/comments/' + toCommentId | 105 | const path = '/api/v1/videos/' + videoId + '/comments/' + toCommentId |
101 | 106 | ||
102 | const body = await unwrapBody<{ comment: VideoComment }>(this.postBodyRequest({ | 107 | const body = await unwrapBody<{ comment: VideoComment }>(this.postBodyRequest({ |
@@ -104,6 +109,7 @@ export class CommentsCommand extends AbstractCommand { | |||
104 | 109 | ||
105 | path, | 110 | path, |
106 | fields: { text }, | 111 | fields: { text }, |
112 | headers: this.buildVideoPasswordHeader(videoPassword), | ||
107 | implicitToken: true, | 113 | implicitToken: true, |
108 | defaultExpectedStatus: HttpStatusCode.OK_200 | 114 | defaultExpectedStatus: HttpStatusCode.OK_200 |
109 | })) | 115 | })) |
diff --git a/shared/server-commands/videos/index.ts b/shared/server-commands/videos/index.ts index c17f6ef20..106d80af0 100644 --- a/shared/server-commands/videos/index.ts +++ b/shared/server-commands/videos/index.ts | |||
@@ -11,9 +11,11 @@ export * from './live-command' | |||
11 | export * from './live' | 11 | export * from './live' |
12 | export * from './playlists-command' | 12 | export * from './playlists-command' |
13 | export * from './services-command' | 13 | export * from './services-command' |
14 | export * from './storyboard-command' | ||
14 | export * from './streaming-playlists-command' | 15 | export * from './streaming-playlists-command' |
15 | export * from './comments-command' | 16 | export * from './comments-command' |
16 | export * from './video-studio-command' | 17 | export * from './video-studio-command' |
17 | export * from './video-token-command' | 18 | export * from './video-token-command' |
18 | export * from './views-command' | 19 | export * from './views-command' |
19 | export * from './videos-command' | 20 | export * from './videos-command' |
21 | export * from './video-passwords-command' | ||
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts index 44d625970..6006d9fe9 100644 --- a/shared/server-commands/videos/live-command.ts +++ b/shared/server-commands/videos/live-command.ts | |||
@@ -120,8 +120,13 @@ export class LiveCommand extends AbstractCommand { | |||
120 | saveReplay: boolean | 120 | saveReplay: boolean |
121 | permanentLive: boolean | 121 | permanentLive: boolean |
122 | privacy?: VideoPrivacy | 122 | privacy?: VideoPrivacy |
123 | videoPasswords?: string[] | ||
123 | }) { | 124 | }) { |
124 | const { saveReplay, permanentLive, privacy = VideoPrivacy.PUBLIC } = options | 125 | const { saveReplay, permanentLive, privacy = VideoPrivacy.PUBLIC, videoPasswords } = options |
126 | |||
127 | const replaySettings = privacy === VideoPrivacy.PASSWORD_PROTECTED | ||
128 | ? { privacy: VideoPrivacy.PRIVATE } | ||
129 | : { privacy } | ||
125 | 130 | ||
126 | const { uuid } = await this.create({ | 131 | const { uuid } = await this.create({ |
127 | ...options, | 132 | ...options, |
@@ -130,9 +135,10 @@ export class LiveCommand extends AbstractCommand { | |||
130 | name: 'live', | 135 | name: 'live', |
131 | permanentLive, | 136 | permanentLive, |
132 | saveReplay, | 137 | saveReplay, |
133 | replaySettings: { privacy }, | 138 | replaySettings, |
134 | channelId: this.server.store.channel.id, | 139 | channelId: this.server.store.channel.id, |
135 | privacy | 140 | privacy, |
141 | videoPasswords | ||
136 | } | 142 | } |
137 | }) | 143 | }) |
138 | 144 | ||
diff --git a/shared/server-commands/videos/storyboard-command.ts b/shared/server-commands/videos/storyboard-command.ts new file mode 100644 index 000000000..06d90fc12 --- /dev/null +++ b/shared/server-commands/videos/storyboard-command.ts | |||
@@ -0,0 +1,19 @@ | |||
1 | import { HttpStatusCode, Storyboard } from '@shared/models' | ||
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
3 | |||
4 | export class StoryboardCommand extends AbstractCommand { | ||
5 | |||
6 | list (options: OverrideCommandOptions & { | ||
7 | id: number | string | ||
8 | }) { | ||
9 | const path = '/api/v1/videos/' + options.id + '/storyboards' | ||
10 | |||
11 | return this.getRequestBody<{ storyboards: Storyboard[] }>({ | ||
12 | ...options, | ||
13 | |||
14 | path, | ||
15 | implicitToken: true, | ||
16 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
17 | }) | ||
18 | } | ||
19 | } | ||
diff --git a/shared/server-commands/videos/video-passwords-command.ts b/shared/server-commands/videos/video-passwords-command.ts new file mode 100644 index 000000000..bf10335b4 --- /dev/null +++ b/shared/server-commands/videos/video-passwords-command.ts | |||
@@ -0,0 +1,55 @@ | |||
1 | import { HttpStatusCode, ResultList, VideoPassword } from '@shared/models' | ||
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
3 | export class VideoPasswordsCommand extends AbstractCommand { | ||
4 | |||
5 | list (options: OverrideCommandOptions & { | ||
6 | videoId: number | string | ||
7 | start?: number | ||
8 | count?: number | ||
9 | sort?: string | ||
10 | }) { | ||
11 | const { start, count, sort, videoId } = options | ||
12 | const path = '/api/v1/videos/' + videoId + '/passwords' | ||
13 | |||
14 | return this.getRequestBody<ResultList<VideoPassword>>({ | ||
15 | ...options, | ||
16 | |||
17 | path, | ||
18 | query: { start, count, sort }, | ||
19 | implicitToken: true, | ||
20 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
21 | }) | ||
22 | } | ||
23 | |||
24 | updateAll (options: OverrideCommandOptions & { | ||
25 | videoId: number | string | ||
26 | passwords: string[] | ||
27 | }) { | ||
28 | const { videoId, passwords } = options | ||
29 | const path = `/api/v1/videos/${videoId}/passwords` | ||
30 | |||
31 | return this.putBodyRequest({ | ||
32 | ...options, | ||
33 | path, | ||
34 | fields: { passwords }, | ||
35 | implicitToken: true, | ||
36 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
37 | }) | ||
38 | } | ||
39 | |||
40 | remove (options: OverrideCommandOptions & { | ||
41 | id: number | ||
42 | videoId: number | string | ||
43 | }) { | ||
44 | const { id, videoId } = options | ||
45 | const path = `/api/v1/videos/${videoId}/passwords/${id}` | ||
46 | |||
47 | return this.deleteRequest({ | ||
48 | ...options, | ||
49 | |||
50 | path, | ||
51 | implicitToken: true, | ||
52 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
53 | }) | ||
54 | } | ||
55 | } | ||
diff --git a/shared/server-commands/videos/video-studio-command.ts b/shared/server-commands/videos/video-studio-command.ts index 9fe467cc2..675cd84b7 100644 --- a/shared/server-commands/videos/video-studio-command.ts +++ b/shared/server-commands/videos/video-studio-command.ts | |||
@@ -25,7 +25,7 @@ export class VideoStudioCommand extends AbstractCommand { | |||
25 | { | 25 | { |
26 | name: 'add-watermark', | 26 | name: 'add-watermark', |
27 | options: { | 27 | options: { |
28 | file: 'thumbnail.png' | 28 | file: 'custom-thumbnail.png' |
29 | } | 29 | } |
30 | }, | 30 | }, |
31 | 31 | ||
diff --git a/shared/server-commands/videos/video-token-command.ts b/shared/server-commands/videos/video-token-command.ts index 0531bee65..c4ed29a8c 100644 --- a/shared/server-commands/videos/video-token-command.ts +++ b/shared/server-commands/videos/video-token-command.ts | |||
@@ -8,12 +8,14 @@ export class VideoTokenCommand extends AbstractCommand { | |||
8 | 8 | ||
9 | create (options: OverrideCommandOptions & { | 9 | create (options: OverrideCommandOptions & { |
10 | videoId: number | string | 10 | videoId: number | string |
11 | videoPassword?: string | ||
11 | }) { | 12 | }) { |
12 | const { videoId } = options | 13 | const { videoId, videoPassword } = options |
13 | const path = '/api/v1/videos/' + videoId + '/token' | 14 | const path = '/api/v1/videos/' + videoId + '/token' |
14 | 15 | ||
15 | return unwrapBody<VideoToken>(this.postBodyRequest({ | 16 | return unwrapBody<VideoToken>(this.postBodyRequest({ |
16 | ...options, | 17 | ...options, |
18 | headers: this.buildVideoPasswordHeader(videoPassword), | ||
17 | 19 | ||
18 | path, | 20 | path, |
19 | implicitToken: true, | 21 | implicitToken: true, |
@@ -23,6 +25,7 @@ export class VideoTokenCommand extends AbstractCommand { | |||
23 | 25 | ||
24 | async getVideoFileToken (options: OverrideCommandOptions & { | 26 | async getVideoFileToken (options: OverrideCommandOptions & { |
25 | videoId: number | string | 27 | videoId: number | string |
28 | videoPassword?: string | ||
26 | }) { | 29 | }) { |
27 | const { files } = await this.create(options) | 30 | const { files } = await this.create(options) |
28 | 31 | ||
diff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.ts index b5df9c325..9602fa7da 100644 --- a/shared/server-commands/videos/videos-command.ts +++ b/shared/server-commands/videos/videos-command.ts | |||
@@ -111,8 +111,9 @@ export class VideosCommand extends AbstractCommand { | |||
111 | rate (options: OverrideCommandOptions & { | 111 | rate (options: OverrideCommandOptions & { |
112 | id: number | string | 112 | id: number | string |
113 | rating: UserVideoRateType | 113 | rating: UserVideoRateType |
114 | videoPassword?: string | ||
114 | }) { | 115 | }) { |
115 | const { id, rating } = options | 116 | const { id, rating, videoPassword } = options |
116 | const path = '/api/v1/videos/' + id + '/rate' | 117 | const path = '/api/v1/videos/' + id + '/rate' |
117 | 118 | ||
118 | return this.putBodyRequest({ | 119 | return this.putBodyRequest({ |
@@ -120,6 +121,7 @@ export class VideosCommand extends AbstractCommand { | |||
120 | 121 | ||
121 | path, | 122 | path, |
122 | fields: { rating }, | 123 | fields: { rating }, |
124 | headers: this.buildVideoPasswordHeader(videoPassword), | ||
123 | implicitToken: true, | 125 | implicitToken: true, |
124 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | 126 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 |
125 | }) | 127 | }) |
@@ -151,6 +153,23 @@ export class VideosCommand extends AbstractCommand { | |||
151 | }) | 153 | }) |
152 | } | 154 | } |
153 | 155 | ||
156 | getWithPassword (options: OverrideCommandOptions & { | ||
157 | id: number | string | ||
158 | password?: string | ||
159 | }) { | ||
160 | const path = '/api/v1/videos/' + options.id | ||
161 | |||
162 | return this.getRequestBody<VideoDetails>({ | ||
163 | ...options, | ||
164 | headers:{ | ||
165 | 'x-peertube-video-password': options.password | ||
166 | }, | ||
167 | path, | ||
168 | implicitToken: false, | ||
169 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
170 | }) | ||
171 | } | ||
172 | |||
154 | getSource (options: OverrideCommandOptions & { | 173 | getSource (options: OverrideCommandOptions & { |
155 | id: number | string | 174 | id: number | string |
156 | }) { | 175 | }) { |
@@ -608,11 +627,13 @@ export class VideosCommand extends AbstractCommand { | |||
608 | nsfw?: boolean | 627 | nsfw?: boolean |
609 | privacy?: VideoPrivacy | 628 | privacy?: VideoPrivacy |
610 | fixture?: string | 629 | fixture?: string |
630 | videoPasswords?: string[] | ||
611 | }) { | 631 | }) { |
612 | const attributes: VideoEdit = { name: options.name } | 632 | const attributes: VideoEdit = { name: options.name } |
613 | if (options.nsfw) attributes.nsfw = options.nsfw | 633 | if (options.nsfw) attributes.nsfw = options.nsfw |
614 | if (options.privacy) attributes.privacy = options.privacy | 634 | if (options.privacy) attributes.privacy = options.privacy |
615 | if (options.fixture) attributes.fixture = options.fixture | 635 | if (options.fixture) attributes.fixture = options.fixture |
636 | if (options.videoPasswords) attributes.videoPasswords = options.videoPasswords | ||
616 | 637 | ||
617 | return this.upload({ ...options, attributes }) | 638 | return this.upload({ ...options, attributes }) |
618 | } | 639 | } |
@@ -665,10 +686,10 @@ export class VideosCommand extends AbstractCommand { | |||
665 | }) | 686 | }) |
666 | } | 687 | } |
667 | 688 | ||
668 | removeAllWebTorrentFiles (options: OverrideCommandOptions & { | 689 | removeAllWebVideoFiles (options: OverrideCommandOptions & { |
669 | videoId: number | string | 690 | videoId: number | string |
670 | }) { | 691 | }) { |
671 | const path = '/api/v1/videos/' + options.videoId + '/webtorrent' | 692 | const path = '/api/v1/videos/' + options.videoId + '/web-videos' |
672 | 693 | ||
673 | return this.deleteRequest({ | 694 | return this.deleteRequest({ |
674 | ...options, | 695 | ...options, |
@@ -679,11 +700,11 @@ export class VideosCommand extends AbstractCommand { | |||
679 | }) | 700 | }) |
680 | } | 701 | } |
681 | 702 | ||
682 | removeWebTorrentFile (options: OverrideCommandOptions & { | 703 | removeWebVideoFile (options: OverrideCommandOptions & { |
683 | videoId: number | string | 704 | videoId: number | string |
684 | fileId: number | 705 | fileId: number |
685 | }) { | 706 | }) { |
686 | const path = '/api/v1/videos/' + options.videoId + '/webtorrent/' + options.fileId | 707 | const path = '/api/v1/videos/' + options.videoId + '/web-videos/' + options.fileId |
687 | 708 | ||
688 | return this.deleteRequest({ | 709 | return this.deleteRequest({ |
689 | ...options, | 710 | ...options, |
@@ -696,7 +717,7 @@ export class VideosCommand extends AbstractCommand { | |||
696 | 717 | ||
697 | runTranscoding (options: OverrideCommandOptions & { | 718 | runTranscoding (options: OverrideCommandOptions & { |
698 | videoId: number | string | 719 | videoId: number | string |
699 | transcodingType: 'hls' | 'webtorrent' | 720 | transcodingType: 'hls' | 'webtorrent' | 'web-video' |
700 | }) { | 721 | }) { |
701 | const path = '/api/v1/videos/' + options.videoId + '/transcoding' | 722 | const path = '/api/v1/videos/' + options.videoId + '/transcoding' |
702 | 723 | ||