Support reinjecting token in private m3u8 playlist

This commit is contained in:
Chocobozzz
2022-12-02 14:47:21 +01:00
parent 04509c4325
commit 71e3e879c0
22 changed files with 391 additions and 48 deletions

View File

@@ -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,

View File

@@ -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
}))