From 71e3e879c0616882ee82a0e44f8c2e5ee9698a3e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 2 Dec 2022 14:47:21 +0100 Subject: Support reinjecting token in private m3u8 playlist --- shared/core-utils/common/url.ts | 9 +++++++++ shared/server-commands/videos/streaming-playlists-command.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'shared') 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 }) { return objUrl.toString() } +function removeQueryParams (url: string) { + const objUrl = new URL(url) + + objUrl.searchParams.forEach((_v, k) => objUrl.searchParams.delete(k)) + + return objUrl.toString() +} + function buildPlaylistLink (playlist: Pick, base?: string) { return (base ?? window.location.origin) + buildPlaylistWatchPath(playlist) } @@ -114,6 +122,7 @@ function decoratePlaylistLink (options: { export { addQueryParams, + removeQueryParams, buildPlaylistLink, 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 { async get (options: OverrideCommandOptions & { url: string + + videoFileToken?: string + reinjectVideoFileToken?: boolean + withRetry?: boolean // default false currentRetry?: number }) { - const { withRetry, currentRetry = 1 } = options + const { videoFileToken, reinjectVideoFileToken, withRetry, currentRetry = 1 } = options try { const result = await unwrapTextOrDecode(this.getRawRequest({ ...options, url: options.url, + query: { + videoFileToken, + reinjectVideoFileToken + }, implicitToken: false, defaultExpectedStatus: HttpStatusCode.OK_200 })) -- cgit v1.2.3