PeerTube/shared/extra-utils/videos/streaming-playlists-command.ts

45 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-07-16 10:42:24 +02:00
import { HttpStatusCode } from '@shared/models'
2021-07-09 10:21:10 +02:00
import { unwrapBody, unwrapText } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class StreamingPlaylistsCommand extends AbstractCommand {
get (options: OverrideCommandOptions & {
url: string
}) {
return unwrapText(this.getRawRequest({
...options,
url: options.url,
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
}))
}
getSegment (options: OverrideCommandOptions & {
url: string
range?: string
}) {
2021-07-09 16:23:01 +02:00
return unwrapBody<Buffer>(this.getRawRequest({
2021-07-09 10:21:10 +02:00
...options,
url: options.url,
range: options.range,
implicitToken: false,
2021-07-09 14:15:11 +02:00
defaultExpectedStatus: HttpStatusCode.OK_200
2021-07-09 10:21:10 +02:00
}))
}
getSegmentSha256 (options: OverrideCommandOptions & {
url: string
}) {
return unwrapBody<{ [ id: string ]: string }>(this.getRawRequest({
...options,
url: options.url,
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
}))
}
}