]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/videos/live-command.ts
Shorter server command names
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / live-command.ts
index 4f03c912783933a16ade8fa61693b6eb2db8ac33..fd66c99243b8b8be6d005a2bc5ba4a6f934ab52a 100644 (file)
@@ -5,12 +5,10 @@ import { omit } from 'lodash'
 import { join } from 'path'
 import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'
 import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
-import { buildServerDirectory, wait } from '../miscs/miscs'
+import { wait } from '../miscs'
 import { unwrapBody } from '../requests'
-import { waitUntilLog } from '../server/servers'
 import { AbstractCommand, OverrideCommandOptions } from '../shared'
 import { sendRTMPStream, testFfmpegStreamError } from './live'
-import { getVideoWithToken } from './videos'
 
 export class LiveCommand extends AbstractCommand {
 
@@ -116,7 +114,7 @@ export class LiveCommand extends AbstractCommand {
     const { resolution, segment, videoUUID } = options
     const segmentName = `${resolution}-00000${segment}.ts`
 
-    return waitUntilLog(this.server, `${videoUUID}/${segmentName}`, 2, false)
+    return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false)
   }
 
   async waitUntilSaved (options: OverrideCommandOptions & {
@@ -125,8 +123,7 @@ export class LiveCommand extends AbstractCommand {
     let video: VideoDetails
 
     do {
-      const res = await getVideoWithToken(this.server.url, options.token ?? this.server.accessToken, options.videoId)
-      video = res.body
+      video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId })
 
       await wait(500)
     } while (video.isLive === true && video.state.id !== VideoState.PUBLISHED)
@@ -135,7 +132,7 @@ export class LiveCommand extends AbstractCommand {
   async countPlaylists (options: OverrideCommandOptions & {
     videoUUID: string
   }) {
-    const basePath = buildServerDirectory(this.server, 'streaming-playlists')
+    const basePath = this.server.servers.buildDirectory('streaming-playlists')
     const hlsPath = join(basePath, 'hls', options.videoUUID)
 
     const files = await readdir(hlsPath)
@@ -150,8 +147,7 @@ export class LiveCommand extends AbstractCommand {
     let video: VideoDetails
 
     do {
-      const res = await getVideoWithToken(this.server.url, options.token ?? this.server.accessToken, options.videoId)
-      video = res.body
+      video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId })
 
       await wait(500)
     } while (video.state.id !== options.state)