aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-12-02 14:47:21 +0100
committerChocobozzz <me@florianbigard.com>2022-12-02 15:25:20 +0100
commit71e3e879c0616882ee82a0e44f8c2e5ee9698a3e (patch)
tree14452d26d240eb6d44178b76fc2dabda4cfc9428 /shared
parent04509c43254dc232c61681ac4bb98e09fd126115 (diff)
downloadPeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.tar.gz
PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.tar.zst
PeerTube-71e3e879c0616882ee82a0e44f8c2e5ee9698a3e.zip
Support reinjecting token in private m3u8 playlist
Diffstat (limited to 'shared')
-rw-r--r--shared/core-utils/common/url.ts9
-rw-r--r--shared/server-commands/videos/streaming-playlists-command.ts10
2 files changed, 18 insertions, 1 deletions
diff --git a/shared/core-utils/common/url.ts b/shared/core-utils/common/url.ts
index d1c399f7b..33fc5ee3a 100644
--- a/shared/core-utils/common/url.ts
+++ b/shared/core-utils/common/url.ts
@@ -11,6 +11,14 @@ function addQueryParams (url: string, params: { [ id: string ]: string }) {
11 return objUrl.toString() 11 return objUrl.toString()
12} 12}
13 13
14function removeQueryParams (url: string) {
15 const objUrl = new URL(url)
16
17 objUrl.searchParams.forEach((_v, k) => objUrl.searchParams.delete(k))
18
19 return objUrl.toString()
20}
21
14function buildPlaylistLink (playlist: Pick<VideoPlaylist, 'shortUUID'>, base?: string) { 22function buildPlaylistLink (playlist: Pick<VideoPlaylist, 'shortUUID'>, base?: string) {
15 return (base ?? window.location.origin) + buildPlaylistWatchPath(playlist) 23 return (base ?? window.location.origin) + buildPlaylistWatchPath(playlist)
16} 24}
@@ -114,6 +122,7 @@ function decoratePlaylistLink (options: {
114 122
115export { 123export {
116 addQueryParams, 124 addQueryParams,
125 removeQueryParams,
117 126
118 buildPlaylistLink, 127 buildPlaylistLink,
119 buildVideoLink, 128 buildVideoLink,
diff --git a/shared/server-commands/videos/streaming-playlists-command.ts b/shared/server-commands/videos/streaming-playlists-command.ts
index 25e446e72..26ab2735f 100644
--- a/shared/server-commands/videos/streaming-playlists-command.ts
+++ b/shared/server-commands/videos/streaming-playlists-command.ts
@@ -7,16 +7,24 @@ export class StreamingPlaylistsCommand extends AbstractCommand {
7 7
8 async get (options: OverrideCommandOptions & { 8 async get (options: OverrideCommandOptions & {
9 url: string 9 url: string
10
11 videoFileToken?: string
12 reinjectVideoFileToken?: boolean
13
10 withRetry?: boolean // default false 14 withRetry?: boolean // default false
11 currentRetry?: number 15 currentRetry?: number
12 }) { 16 }) {
13 const { withRetry, currentRetry = 1 } = options 17 const { videoFileToken, reinjectVideoFileToken, withRetry, currentRetry = 1 } = options
14 18
15 try { 19 try {
16 const result = await unwrapTextOrDecode(this.getRawRequest({ 20 const result = await unwrapTextOrDecode(this.getRawRequest({
17 ...options, 21 ...options,
18 22
19 url: options.url, 23 url: options.url,
24 query: {
25 videoFileToken,
26 reinjectVideoFileToken
27 },
20 implicitToken: false, 28 implicitToken: false,
21 defaultExpectedStatus: HttpStatusCode.OK_200 29 defaultExpectedStatus: HttpStatusCode.OK_200
22 })) 30 }))