1 import { HttpStatusCode } from '@shared/models'
2 import { ResultList, VideoCaption } from '@shared/models'
3 import { buildAbsoluteFixturePath } from '../miscs'
4 import { AbstractCommand, OverrideCommandOptions } from '../shared'
6 export class CaptionsCommand extends AbstractCommand {
8 createVideoCaption (options: OverrideCommandOptions & {
9 videoId: string | number
14 const { videoId, language, fixture, mimeType } = options
16 const path = '/api/v1/videos/' + videoId + '/captions/' + language
18 const captionfile = buildAbsoluteFixturePath(fixture)
19 const captionfileAttach = mimeType
20 ? [ captionfile, { contentType: mimeType } ]
23 return this.putUploadRequest({
29 captionfile: captionfileAttach
32 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
36 listVideoCaptions (options: OverrideCommandOptions & {
37 videoId: string | number
39 const { videoId } = options
40 const path = '/api/v1/videos/' + videoId + '/captions'
42 return this.getRequestBody<ResultList<VideoCaption>>({
47 defaultExpectedStatus: HttpStatusCode.OK_200
51 deleteVideoCaption (options: OverrideCommandOptions & {
52 videoId: string | number
55 const { videoId, language } = options
56 const path = '/api/v1/videos/' + videoId + '/captions/' + language
58 return this.deleteRequest({
63 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204