mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Support reinjecting token in private m3u8 playlist
This commit is contained in:
@@ -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<VideoPlaylist, 'shortUUID'>, base?: string) {
|
||||
return (base ?? window.location.origin) + buildPlaylistWatchPath(playlist)
|
||||
}
|
||||
@@ -114,6 +122,7 @@ function decoratePlaylistLink (options: {
|
||||
|
||||
export {
|
||||
addQueryParams,
|
||||
removeQueryParams,
|
||||
|
||||
buildPlaylistLink,
|
||||
buildVideoLink,
|
||||
|
||||
@@ -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
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user