X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fextra-utils%2Fvideos%2Fstreaming-playlists.ts;h=a224b8f5f67a78fd2595c1ba8255e1889af58d6f;hb=764b1a14fc494f2cfd7ea590d2f07b01df65c7ad;hp=db40c27befc96fd6743fdc2b1a4095e435be2986;hpb=83903cb65d531a6b6b91715387493ba8312b264d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts index db40c27be..a224b8f5f 100644 --- a/shared/extra-utils/videos/streaming-playlists.ts +++ b/shared/extra-utils/videos/streaming-playlists.ts @@ -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' @@ -15,11 +16,11 @@ async function checkSegmentHash (options: { const { server, baseUrlPlaylist, baseUrlSegment, videoUUID, 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}/${videoUUID}/${removeFragmentedMP4Ext(videoName)}.m3u8` }) + const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist) const length = parseInt(matches[1], 10)