aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/server-commands/videos/streaming-playlists-command.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/server-commands/videos/streaming-playlists-command.ts')
-rw-r--r--shared/server-commands/videos/streaming-playlists-command.ts36
1 files changed, 28 insertions, 8 deletions
diff --git a/shared/server-commands/videos/streaming-playlists-command.ts b/shared/server-commands/videos/streaming-playlists-command.ts
index 7f923d001..25e446e72 100644
--- a/shared/server-commands/videos/streaming-playlists-command.ts
+++ b/shared/server-commands/videos/streaming-playlists-command.ts
@@ -1,19 +1,39 @@
1import { wait } from '@shared/core-utils'
1import { HttpStatusCode } from '@shared/models' 2import { HttpStatusCode } from '@shared/models'
2import { unwrapBody, unwrapTextOrDecode, unwrapBodyOrDecodeToJSON } from '../requests' 3import { unwrapBody, unwrapBodyOrDecodeToJSON, unwrapTextOrDecode } from '../requests'
3import { AbstractCommand, OverrideCommandOptions } from '../shared' 4import { AbstractCommand, OverrideCommandOptions } from '../shared'
4 5
5export class StreamingPlaylistsCommand extends AbstractCommand { 6export class StreamingPlaylistsCommand extends AbstractCommand {
6 7
7 get (options: OverrideCommandOptions & { 8 async get (options: OverrideCommandOptions & {
8 url: string 9 url: string
10 withRetry?: boolean // default false
11 currentRetry?: number
9 }) { 12 }) {
10 return unwrapTextOrDecode(this.getRawRequest({ 13 const { withRetry, currentRetry = 1 } = options
11 ...options,
12 14
13 url: options.url, 15 try {
14 implicitToken: false, 16 const result = await unwrapTextOrDecode(this.getRawRequest({
15 defaultExpectedStatus: HttpStatusCode.OK_200 17 ...options,
16 })) 18
19 url: options.url,
20 implicitToken: false,
21 defaultExpectedStatus: HttpStatusCode.OK_200
22 }))
23
24 return result
25 } catch (err) {
26 if (!withRetry || currentRetry > 5) throw err
27
28 await wait(100)
29
30 return this.get({
31 ...options,
32
33 withRetry,
34 currentRetry: currentRetry + 1
35 })
36 }
17 } 37 }
18 38
19 getFragmentedSegment (options: OverrideCommandOptions & { 39 getFragmentedSegment (options: OverrideCommandOptions & {