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/index.ts1
-rw-r--r--shared/server-commands/videos/live-command.ts26
-rw-r--r--shared/server-commands/videos/live.ts7
-rw-r--r--shared/server-commands/videos/video-token-command.ts31
-rw-r--r--shared/server-commands/videos/videos-command.ts6
5 files changed, 67 insertions, 4 deletions
diff --git a/shared/server-commands/videos/index.ts b/shared/server-commands/videos/index.ts
index b4d6fa37b..c17f6ef20 100644
--- a/shared/server-commands/videos/index.ts
+++ b/shared/server-commands/videos/index.ts
@@ -14,5 +14,6 @@ export * from './services-command'
14export * from './streaming-playlists-command' 14export * from './streaming-playlists-command'
15export * from './comments-command' 15export * from './comments-command'
16export * from './video-studio-command' 16export * from './video-studio-command'
17export * from './video-token-command'
17export * from './views-command' 18export * from './views-command'
18export * from './videos-command' 19export * from './videos-command'
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts
index b163f7189..de193fa49 100644
--- a/shared/server-commands/videos/live-command.ts
+++ b/shared/server-commands/videos/live-command.ts
@@ -12,6 +12,7 @@ import {
12 ResultList, 12 ResultList,
13 VideoCreateResult, 13 VideoCreateResult,
14 VideoDetails, 14 VideoDetails,
15 VideoPrivacy,
15 VideoState 16 VideoState
16} from '@shared/models' 17} from '@shared/models'
17import { unwrapBody } from '../requests' 18import { unwrapBody } from '../requests'
@@ -115,6 +116,31 @@ export class LiveCommand extends AbstractCommand {
115 return body.video 116 return body.video
116 } 117 }
117 118
119 async quickCreate (options: OverrideCommandOptions & {
120 saveReplay: boolean
121 permanentLive: boolean
122 privacy?: VideoPrivacy
123 }) {
124 const { saveReplay, permanentLive, privacy } = options
125
126 const { uuid } = await this.create({
127 ...options,
128
129 fields: {
130 name: 'live',
131 permanentLive,
132 saveReplay,
133 channelId: this.server.store.channel.id,
134 privacy
135 }
136 })
137
138 const video = await this.server.videos.getWithToken({ id: uuid })
139 const live = await this.get({ videoId: uuid })
140
141 return { video, live }
142 }
143
118 // --------------------------------------------------------------------------- 144 // ---------------------------------------------------------------------------
119 145
120 async sendRTMPStreamInVideo (options: OverrideCommandOptions & { 146 async sendRTMPStreamInVideo (options: OverrideCommandOptions & {
diff --git a/shared/server-commands/videos/live.ts b/shared/server-commands/videos/live.ts
index 0d9c32aab..ee7444b64 100644
--- a/shared/server-commands/videos/live.ts
+++ b/shared/server-commands/videos/live.ts
@@ -1,6 +1,6 @@
1import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg' 1import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
2import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' 2import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
3import { VideoDetails, VideoInclude } from '@shared/models' 3import { VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models'
4import { PeerTubeServer } from '../server/server' 4import { PeerTubeServer } from '../server/server'
5 5
6function sendRTMPStream (options: { 6function sendRTMPStream (options: {
@@ -98,7 +98,10 @@ async function waitUntilLiveReplacedByReplayOnAllServers (servers: PeerTubeServe
98} 98}
99 99
100async function findExternalSavedVideo (server: PeerTubeServer, liveDetails: VideoDetails) { 100async function findExternalSavedVideo (server: PeerTubeServer, liveDetails: VideoDetails) {
101 const { data } = await server.videos.list({ token: server.accessToken, sort: '-publishedAt', include: VideoInclude.BLACKLISTED }) 101 const include = VideoInclude.BLACKLISTED
102 const privacyOneOf = [ VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.PUBLIC, VideoPrivacy.UNLISTED ]
103
104 const { data } = await server.videos.list({ token: server.accessToken, sort: '-publishedAt', include, privacyOneOf })
102 105
103 return data.find(v => v.name === liveDetails.name + ' - ' + new Date(liveDetails.publishedAt).toLocaleString()) 106 return data.find(v => v.name === liveDetails.name + ' - ' + new Date(liveDetails.publishedAt).toLocaleString())
104} 107}
diff --git a/shared/server-commands/videos/video-token-command.ts b/shared/server-commands/videos/video-token-command.ts
new file mode 100644
index 000000000..0531bee65
--- /dev/null
+++ b/shared/server-commands/videos/video-token-command.ts
@@ -0,0 +1,31 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
2
3import { HttpStatusCode, VideoToken } from '@shared/models'
4import { unwrapBody } from '../requests'
5import { AbstractCommand, OverrideCommandOptions } from '../shared'
6
7export class VideoTokenCommand extends AbstractCommand {
8
9 create (options: OverrideCommandOptions & {
10 videoId: number | string
11 }) {
12 const { videoId } = options
13 const path = '/api/v1/videos/' + videoId + '/token'
14
15 return unwrapBody<VideoToken>(this.postBodyRequest({
16 ...options,
17
18 path,
19 implicitToken: true,
20 defaultExpectedStatus: HttpStatusCode.OK_200
21 }))
22 }
23
24 async getVideoFileToken (options: OverrideCommandOptions & {
25 videoId: number | string
26 }) {
27 const { files } = await this.create(options)
28
29 return files.token
30 }
31}
diff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.ts
index 168391523..5ec3b6ba8 100644
--- a/shared/server-commands/videos/videos-command.ts
+++ b/shared/server-commands/videos/videos-command.ts
@@ -342,8 +342,9 @@ export class VideosCommand extends AbstractCommand {
342 async upload (options: OverrideCommandOptions & { 342 async upload (options: OverrideCommandOptions & {
343 attributes?: VideoEdit 343 attributes?: VideoEdit
344 mode?: 'legacy' | 'resumable' // default legacy 344 mode?: 'legacy' | 'resumable' // default legacy
345 waitTorrentGeneration?: boolean // default true
345 } = {}) { 346 } = {}) {
346 const { mode = 'legacy' } = options 347 const { mode = 'legacy', waitTorrentGeneration } = options
347 let defaultChannelId = 1 348 let defaultChannelId = 1
348 349
349 try { 350 try {
@@ -377,7 +378,7 @@ export class VideosCommand extends AbstractCommand {
377 378
378 // Wait torrent generation 379 // Wait torrent generation
379 const expectedStatus = this.buildExpectedStatus({ ...options, defaultExpectedStatus: HttpStatusCode.OK_200 }) 380 const expectedStatus = this.buildExpectedStatus({ ...options, defaultExpectedStatus: HttpStatusCode.OK_200 })
380 if (expectedStatus === HttpStatusCode.OK_200) { 381 if (expectedStatus === HttpStatusCode.OK_200 && waitTorrentGeneration) {
381 let video: VideoDetails 382 let video: VideoDetails
382 383
383 do { 384 do {
@@ -692,6 +693,7 @@ export class VideosCommand extends AbstractCommand {
692 'categoryOneOf', 693 'categoryOneOf',
693 'licenceOneOf', 694 'licenceOneOf',
694 'languageOneOf', 695 'languageOneOf',
696 'privacyOneOf',
695 'tagsOneOf', 697 'tagsOneOf',
696 'tagsAllOf', 698 'tagsAllOf',
697 'isLocal', 699 'isLocal',