]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/server-commands/videos/live-command.ts
Correctly wait for live segment generation
[github/Chocobozzz/PeerTube.git] / shared / server-commands / videos / live-command.ts
index 3273e3a8fe8455460e582eebc03a0170362500f5..73f4eefd331a94086c625b55b41c1898d0f6aeff 100644 (file)
@@ -121,7 +121,7 @@ export class LiveCommand extends AbstractCommand {
     permanentLive: boolean
     privacy?: VideoPrivacy
   }) {
-    const { saveReplay, permanentLive, privacy } = options
+    const { saveReplay, permanentLive, privacy = VideoPrivacy.PUBLIC } = options
 
     const { uuid } = await this.create({
       ...options,
@@ -213,6 +213,7 @@ export class LiveCommand extends AbstractCommand {
 
     while (error) {
       try {
+        // Check fragment exists
         await this.getRawRequest({
           ...options,
 
@@ -224,12 +225,16 @@ export class LiveCommand extends AbstractCommand {
         const video = await server.videos.get({ id: videoUUID })
         const hlsPlaylist = video.streamingPlaylists[0]
 
-        const shaBody = await server.streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url })
-
+        // Check SHA generation
+        const shaBody = await server.streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url, withRetry: objectStorage })
         if (!shaBody[segmentName]) {
           throw new Error('Segment SHA does not exist')
         }
 
+        // Check fragment is in m3u8 playlist
+        const subPlaylist = await server.streamingPlaylists.get({ url: `${baseUrl}/${video.uuid}/${playlistNumber}.m3u8` })
+        if (!subPlaylist.includes(segmentName)) throw new Error('Fragment does not exist in playlist')
+
         error = false
       } catch {
         error = true