aboutsummaryrefslogblamecommitdiffhomepage
path: root/shared/server-commands/videos/streaming-playlists-command.ts
blob: 5d40d35cb9e06b1d0d90cb0ba0c14a39edaf177d (plain) (tree)
1
2
3
4
5
6
7
8
9
                                               
                                                                                      






                                                                   
                                                  











                                                  
                                                  




                           
                                                  





                                                       
                                                                                    







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

  getSegment (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
    }))
  }
}