diff options
Diffstat (limited to 'shared/server-commands/videos/streaming-playlists-command.ts')
-rw-r--r-- | shared/server-commands/videos/streaming-playlists-command.ts | 36 |
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 @@ | |||
1 | import { wait } from '@shared/core-utils' | ||
1 | import { HttpStatusCode } from '@shared/models' | 2 | import { HttpStatusCode } from '@shared/models' |
2 | import { unwrapBody, unwrapTextOrDecode, unwrapBodyOrDecodeToJSON } from '../requests' | 3 | import { unwrapBody, unwrapBodyOrDecodeToJSON, unwrapTextOrDecode } from '../requests' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 5 | ||
5 | export class StreamingPlaylistsCommand extends AbstractCommand { | 6 | export 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 & { |