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 {
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 & {
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)
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)
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)