]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/videos/streaming-playlists.ts
Add transcoding fail message in client
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / streaming-playlists.ts
index db40c27befc96fd6743fdc2b1a4095e435be2986..6671e3fa6bc6306fff222a11e40477a3425e1445 100644 (file)
@@ -1,6 +1,7 @@
 import { expect } from 'chai'
 import { basename } from 'path'
 import { sha256 } from '@server/helpers/core-utils'
+import { removeFragmentedMP4Ext } from '@shared/core-utils'
 import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models'
 import { PeerTubeServer } from '../server'
 
@@ -8,18 +9,17 @@ async function checkSegmentHash (options: {
   server: PeerTubeServer
   baseUrlPlaylist: string
   baseUrlSegment: string
-  videoUUID: string
   resolution: number
   hlsPlaylist: VideoStreamingPlaylist
 }) {
-  const { server, baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist } = options
+  const { server, baseUrlPlaylist, baseUrlSegment, resolution, hlsPlaylist } = options
   const command = server.streamingPlaylists
 
-  const playlist = await command.get({ url: `${baseUrlPlaylist}/${videoUUID}/${resolution}.m3u8` })
-
   const file = hlsPlaylist.files.find(f => f.resolution.id === resolution)
   const videoName = basename(file.fileUrl)
 
+  const playlist = await command.get({ url: `${baseUrlPlaylist}/${removeFragmentedMP4Ext(videoName)}.m3u8` })
+
   const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist)
 
   const length = parseInt(matches[1], 10)
@@ -27,7 +27,7 @@ async function checkSegmentHash (options: {
   const range = `${offset}-${offset + length - 1}`
 
   const segmentBody = await command.getSegment({
-    url: `${baseUrlSegment}/${videoUUID}/${videoName}`,
+    url: `${baseUrlSegment}/${videoName}`,
     expectedStatus: HttpStatusCode.PARTIAL_CONTENT_206,
     range: `bytes=${range}`
   })