aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/server-commands/videos/streaming-playlists-command.ts
blob: 7f923d001a39b0f5ddefc61f397d598b8594cf40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { HttpStatusCode } from '@shared/models'
import { unwrapBody, unwrapTextOrDecode, unwrapBodyOrDecodeToJSON } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'

export class StreamingPlaylistsCommand extends AbstractCommand {

  get (options: OverrideCommandOptions & {
    url: string
  }) {
    return unwrapTextOrDecode(this.getRawRequest({
      ...options,

      url: options.url,
      implicitToken: false,
      defaultExpectedStatus: HttpStatusCode.OK_200
    }))
  }

  getFragmentedSegment (options: OverrideCommandOptions & {
    url: string
    range?: string
  }) {
    return unwrapBody<Buffer>(this.getRawRequest({
      ...options,

      url: options.url,
      range: options.range,
      implicitToken: false,
      defaultExpectedStatus: HttpStatusCode.OK_200
    }))
  }

  getSegmentSha256 (options: OverrideCommandOptions & {
    url: string
  }) {
    return unwrapBodyOrDecodeToJSON<{ [ id: string ]: string }>(this.getRawRequest({
      ...options,

      url: options.url,
      implicitToken: false,
      defaultExpectedStatus: HttpStatusCode.OK_200
    }))
  }
}