]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/videos/streaming-playlists.ts
chore(refactor): remove shared folder dependencies to the server
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / streaming-playlists.ts
index a224b8f5f67a78fd2595c1ba8255e1889af58d6f..0451c0efefb7b370fdd69d5165aaf85849df6c8e 100644 (file)
@@ -1,6 +1,6 @@
 import { expect } from 'chai'
 import { basename } from 'path'
-import { sha256 } from '@server/helpers/core-utils'
+import { sha256 } from '@shared/core-utils/crypto'
 import { removeFragmentedMP4Ext } from '@shared/core-utils'
 import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models'
 import { PeerTubeServer } from '../server'
@@ -9,17 +9,16 @@ 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 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 playlist = await command.get({ url: `${baseUrlPlaylist}/${removeFragmentedMP4Ext(videoName)}.m3u8` })
 
   const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist)
 
@@ -28,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}`
   })