X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fserver-commands%2Fvideos%2Flive-command.ts;h=cc9502c6f1efe9735092dd84b1cece35eba90857;hb=508c1b1e9f3b26752a961e945b7fa59b72b30827;hp=a0e0c7c8fb1a4c3ec08fc3029e36fc5fefbea55c;hpb=bbae45c32ea41ba4926b291fac5f594c94d5aa9d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts index a0e0c7c8f..cc9502c6f 100644 --- a/shared/server-commands/videos/live-command.ts +++ b/shared/server-commands/videos/live-command.ts @@ -12,6 +12,7 @@ import { ResultList, VideoCreateResult, VideoDetails, + VideoPrivacy, VideoState } from '@shared/models' import { unwrapBody } from '../requests' @@ -115,6 +116,31 @@ export class LiveCommand extends AbstractCommand { return body.video } + async quickCreate (options: OverrideCommandOptions & { + saveReplay: boolean + permanentLive: boolean + privacy?: VideoPrivacy + }) { + const { saveReplay, permanentLive, privacy } = options + + const { uuid } = await this.create({ + ...options, + + fields: { + name: 'live', + permanentLive, + saveReplay, + channelId: this.server.store.channel.id, + privacy + } + }) + + const video = await this.server.videos.getWithToken({ id: uuid }) + const live = await this.get({ videoId: uuid }) + + return { video, live } + } + // --------------------------------------------------------------------------- async sendRTMPStreamInVideo (options: OverrideCommandOptions & { @@ -171,7 +197,7 @@ export class LiveCommand extends AbstractCommand { const segmentName = `${playlistNumber}-00000${segment}.ts` const baseUrl = objectStorage - ? ObjectStorageCommand.getPlaylistBaseUrl() + 'hls' + ? ObjectStorageCommand.getMockPlaylistBaseUrl() + 'hls' : server.url + '/static/streaming-playlists/hls' let error = true @@ -186,6 +212,15 @@ export class LiveCommand extends AbstractCommand { defaultExpectedStatus: HttpStatusCode.OK_200 }) + const video = await server.videos.get({ id: videoUUID }) + const hlsPlaylist = video.streamingPlaylists[0] + + const shaBody = await server.streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url }) + + if (!shaBody[segmentName]) { + throw new Error('Segment SHA does not exist') + } + error = false } catch { error = true @@ -218,7 +253,7 @@ export class LiveCommand extends AbstractCommand { const segmentName = `${playlistNumber}-00000${segment}.ts` const baseUrl = objectStorage - ? ObjectStorageCommand.getPlaylistBaseUrl() + ? ObjectStorageCommand.getMockPlaylistBaseUrl() : `${this.server.url}/static/streaming-playlists/hls` const url = `${baseUrl}/${videoUUID}/${segmentName}` @@ -240,7 +275,7 @@ export class LiveCommand extends AbstractCommand { const { playlistName, videoUUID, objectStorage = false } = options const baseUrl = objectStorage - ? ObjectStorageCommand.getPlaylistBaseUrl() + ? ObjectStorageCommand.getMockPlaylistBaseUrl() : `${this.server.url}/static/streaming-playlists/hls` const url = `${baseUrl}/${videoUUID}/${playlistName}`