diff options
Diffstat (limited to 'shared/extra-utils/videos')
-rw-r--r-- | shared/extra-utils/videos/live-command.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/videos/live.ts | 7 | ||||
-rw-r--r-- | shared/extra-utils/videos/streaming-playlists-command.ts | 6 | ||||
-rw-r--r-- | shared/extra-utils/videos/streaming-playlists.ts | 7 | ||||
-rw-r--r-- | shared/extra-utils/videos/videos-command.ts | 11 |
5 files changed, 25 insertions, 8 deletions
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts index 81ae458e0..74f5d3089 100644 --- a/shared/extra-utils/videos/live-command.ts +++ b/shared/extra-utils/videos/live-command.ts | |||
@@ -126,7 +126,7 @@ export class LiveCommand extends AbstractCommand { | |||
126 | video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId }) | 126 | video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId }) |
127 | 127 | ||
128 | await wait(500) | 128 | await wait(500) |
129 | } while (video.isLive === true && video.state.id !== VideoState.PUBLISHED) | 129 | } while (video.isLive === true || video.state.id !== VideoState.PUBLISHED) |
130 | } | 130 | } |
131 | 131 | ||
132 | async countPlaylists (options: OverrideCommandOptions & { | 132 | async countPlaylists (options: OverrideCommandOptions & { |
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts index 9a6df07a8..29f99ed6d 100644 --- a/shared/extra-utils/videos/live.ts +++ b/shared/extra-utils/videos/live.ts | |||
@@ -89,6 +89,12 @@ async function waitUntilLivePublishedOnAllServers (servers: PeerTubeServer[], vi | |||
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | async function waitUntilLiveSavedOnAllServers (servers: PeerTubeServer[], videoId: string) { | ||
93 | for (const server of servers) { | ||
94 | await server.live.waitUntilSaved({ videoId }) | ||
95 | } | ||
96 | } | ||
97 | |||
92 | async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) { | 98 | async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) { |
93 | const basePath = server.servers.buildDirectory('streaming-playlists') | 99 | const basePath = server.servers.buildDirectory('streaming-playlists') |
94 | const hlsPath = join(basePath, 'hls', videoUUID) | 100 | const hlsPath = join(basePath, 'hls', videoUUID) |
@@ -126,5 +132,6 @@ export { | |||
126 | testFfmpegStreamError, | 132 | testFfmpegStreamError, |
127 | stopFfmpeg, | 133 | stopFfmpeg, |
128 | waitUntilLivePublishedOnAllServers, | 134 | waitUntilLivePublishedOnAllServers, |
135 | waitUntilLiveSavedOnAllServers, | ||
129 | checkLiveCleanupAfterSave | 136 | checkLiveCleanupAfterSave |
130 | } | 137 | } |
diff --git a/shared/extra-utils/videos/streaming-playlists-command.ts b/shared/extra-utils/videos/streaming-playlists-command.ts index 9662685da..5d40d35cb 100644 --- a/shared/extra-utils/videos/streaming-playlists-command.ts +++ b/shared/extra-utils/videos/streaming-playlists-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { HttpStatusCode } from '@shared/models' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { unwrapBody, unwrapText } from '../requests' | 2 | import { unwrapBody, unwrapTextOrDecode, unwrapBodyOrDecodeToJSON } from '../requests' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class StreamingPlaylistsCommand extends AbstractCommand { | 5 | export class StreamingPlaylistsCommand extends AbstractCommand { |
@@ -7,7 +7,7 @@ export class StreamingPlaylistsCommand extends AbstractCommand { | |||
7 | get (options: OverrideCommandOptions & { | 7 | get (options: OverrideCommandOptions & { |
8 | url: string | 8 | url: string |
9 | }) { | 9 | }) { |
10 | return unwrapText(this.getRawRequest({ | 10 | return unwrapTextOrDecode(this.getRawRequest({ |
11 | ...options, | 11 | ...options, |
12 | 12 | ||
13 | url: options.url, | 13 | url: options.url, |
@@ -33,7 +33,7 @@ export class StreamingPlaylistsCommand extends AbstractCommand { | |||
33 | getSegmentSha256 (options: OverrideCommandOptions & { | 33 | getSegmentSha256 (options: OverrideCommandOptions & { |
34 | url: string | 34 | url: string |
35 | }) { | 35 | }) { |
36 | return unwrapBody<{ [ id: string ]: string }>(this.getRawRequest({ | 36 | return unwrapBodyOrDecodeToJSON<{ [ id: string ]: string }>(this.getRawRequest({ |
37 | ...options, | 37 | ...options, |
38 | 38 | ||
39 | url: options.url, | 39 | url: options.url, |
diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts index a224b8f5f..6671e3fa6 100644 --- a/shared/extra-utils/videos/streaming-playlists.ts +++ b/shared/extra-utils/videos/streaming-playlists.ts | |||
@@ -9,17 +9,16 @@ async function checkSegmentHash (options: { | |||
9 | server: PeerTubeServer | 9 | server: PeerTubeServer |
10 | baseUrlPlaylist: string | 10 | baseUrlPlaylist: string |
11 | baseUrlSegment: string | 11 | baseUrlSegment: string |
12 | videoUUID: string | ||
13 | resolution: number | 12 | resolution: number |
14 | hlsPlaylist: VideoStreamingPlaylist | 13 | hlsPlaylist: VideoStreamingPlaylist |
15 | }) { | 14 | }) { |
16 | const { server, baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist } = options | 15 | const { server, baseUrlPlaylist, baseUrlSegment, resolution, hlsPlaylist } = options |
17 | const command = server.streamingPlaylists | 16 | const command = server.streamingPlaylists |
18 | 17 | ||
19 | const file = hlsPlaylist.files.find(f => f.resolution.id === resolution) | 18 | const file = hlsPlaylist.files.find(f => f.resolution.id === resolution) |
20 | const videoName = basename(file.fileUrl) | 19 | const videoName = basename(file.fileUrl) |
21 | 20 | ||
22 | const playlist = await command.get({ url: `${baseUrlPlaylist}/${videoUUID}/${removeFragmentedMP4Ext(videoName)}.m3u8` }) | 21 | const playlist = await command.get({ url: `${baseUrlPlaylist}/${removeFragmentedMP4Ext(videoName)}.m3u8` }) |
23 | 22 | ||
24 | const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist) | 23 | const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist) |
25 | 24 | ||
@@ -28,7 +27,7 @@ async function checkSegmentHash (options: { | |||
28 | const range = `${offset}-${offset + length - 1}` | 27 | const range = `${offset}-${offset + length - 1}` |
29 | 28 | ||
30 | const segmentBody = await command.getSegment({ | 29 | const segmentBody = await command.getSegment({ |
31 | url: `${baseUrlSegment}/${videoUUID}/${videoName}`, | 30 | url: `${baseUrlSegment}/${videoName}`, |
32 | expectedStatus: HttpStatusCode.PARTIAL_CONTENT_206, | 31 | expectedStatus: HttpStatusCode.PARTIAL_CONTENT_206, |
33 | range: `bytes=${range}` | 32 | range: `bytes=${range}` |
34 | }) | 33 | }) |
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts index 33725bfdc..d35339c8d 100644 --- a/shared/extra-utils/videos/videos-command.ts +++ b/shared/extra-utils/videos/videos-command.ts | |||
@@ -188,6 +188,17 @@ export class VideosCommand extends AbstractCommand { | |||
188 | return id | 188 | return id |
189 | } | 189 | } |
190 | 190 | ||
191 | async listFiles (options: OverrideCommandOptions & { | ||
192 | id: number | string | ||
193 | }) { | ||
194 | const video = await this.get(options) | ||
195 | |||
196 | const files = video.files || [] | ||
197 | const hlsFiles = video.streamingPlaylists[0]?.files || [] | ||
198 | |||
199 | return files.concat(hlsFiles) | ||
200 | } | ||
201 | |||
191 | // --------------------------------------------------------------------------- | 202 | // --------------------------------------------------------------------------- |
192 | 203 | ||
193 | listMyVideos (options: OverrideCommandOptions & { | 204 | listMyVideos (options: OverrideCommandOptions & { |