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'
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 videoName = `${videoUUID}-${resolution}-fragmented.mp4`
+ const playlist = await command.get({ url: `${baseUrlPlaylist}/${removeFragmentedMP4Ext(videoName)}.m3u8` })
const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist)
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}`
})