aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-23 11:20:00 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-07-26 11:29:31 +0200
commit764b1a14fc494f2cfd7ea590d2f07b01df65c7ad (patch)
tree198ca5f242c63a205a05fa4cfd6d063277c541fd /shared/extra-utils/videos
parent83903cb65d531a6b6b91715387493ba8312b264d (diff)
downloadPeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.gz
PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.zst
PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.zip
Use random names for VOD HLS playlists
Diffstat (limited to 'shared/extra-utils/videos')
-rw-r--r--shared/extra-utils/videos/live.ts18
-rw-r--r--shared/extra-utils/videos/streaming-playlists.ts5
2 files changed, 15 insertions, 8 deletions
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts
index 502964b1a..94f5f5b59 100644
--- a/shared/extra-utils/videos/live.ts
+++ b/shared/extra-utils/videos/live.ts
@@ -76,7 +76,7 @@ async function waitUntilLivePublishedOnAllServers (servers: PeerTubeServer[], vi
76 } 76 }
77} 77}
78 78
79async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) { 79async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) {
80 const basePath = server.servers.buildDirectory('streaming-playlists') 80 const basePath = server.servers.buildDirectory('streaming-playlists')
81 const hlsPath = join(basePath, 'hls', videoUUID) 81 const hlsPath = join(basePath, 'hls', videoUUID)
82 82
@@ -93,12 +93,18 @@ async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, reso
93 expect(files).to.have.lengthOf(resolutions.length * 2 + 2) 93 expect(files).to.have.lengthOf(resolutions.length * 2 + 2)
94 94
95 for (const resolution of resolutions) { 95 for (const resolution of resolutions) {
96 expect(files).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) 96 const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`))
97 expect(files).to.contain(`${resolution}.m3u8`) 97 expect(fragmentedFile).to.exist
98
99 const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`))
100 expect(playlistFile).to.exist
98 } 101 }
99 102
100 expect(files).to.contain('master.m3u8') 103 const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8'))
101 expect(files).to.contain('segments-sha256.json') 104 expect(masterPlaylistFile).to.exist
105
106 const shaFile = files.find(f => f.endsWith('-segments-sha256.json'))
107 expect(shaFile).to.exist
102} 108}
103 109
104export { 110export {
@@ -107,5 +113,5 @@ export {
107 testFfmpegStreamError, 113 testFfmpegStreamError,
108 stopFfmpeg, 114 stopFfmpeg,
109 waitUntilLivePublishedOnAllServers, 115 waitUntilLivePublishedOnAllServers,
110 checkLiveCleanup 116 checkLiveCleanupAfterSave
111} 117}
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 @@
1import { expect } from 'chai' 1import { expect } from 'chai'
2import { basename } from 'path' 2import { basename } from 'path'
3import { sha256 } from '@server/helpers/core-utils' 3import { sha256 } from '@server/helpers/core-utils'
4import { removeFragmentedMP4Ext } from '@shared/core-utils'
4import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models' 5import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models'
5import { PeerTubeServer } from '../server' 6import { PeerTubeServer } from '../server'
6 7
@@ -15,11 +16,11 @@ async function checkSegmentHash (options: {
15 const { server, baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist } = options 16 const { server, baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist } = options
16 const command = server.streamingPlaylists 17 const command = server.streamingPlaylists
17 18
18 const playlist = await command.get({ url: `${baseUrlPlaylist}/${videoUUID}/${resolution}.m3u8` })
19
20 const file = hlsPlaylist.files.find(f => f.resolution.id === resolution) 19 const file = hlsPlaylist.files.find(f => f.resolution.id === resolution)
21 const videoName = basename(file.fileUrl) 20 const videoName = basename(file.fileUrl)
22 21
22 const playlist = await command.get({ url: `${baseUrlPlaylist}/${videoUUID}/${removeFragmentedMP4Ext(videoName)}.m3u8` })
23
23 const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist) 24 const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist)
24 25
25 const length = parseInt(matches[1], 10) 26 const length = parseInt(matches[1], 10)