1 import { HttpStatusCode, ResultList, VideoCaption } from '@shared/models'
2 import { buildAbsoluteFixturePath } from '../miscs'
3 import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 export class CaptionsCommand extends AbstractCommand {
7 add (options: OverrideCommandOptions & {
8 videoId: string | number
13 const { videoId, language, fixture, mimeType } = options
15 const path = '/api/v1/videos/' + videoId + '/captions/' + language
17 const captionfile = buildAbsoluteFixturePath(fixture)
18 const captionfileAttach = mimeType
19 ? [ captionfile, { contentType: mimeType } ]
22 return this.putUploadRequest({
28 captionfile: captionfileAttach
31 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
35 list (options: OverrideCommandOptions & {
36 videoId: string | number
38 const { videoId } = options
39 const path = '/api/v1/videos/' + videoId + '/captions'
41 return this.getRequestBody<ResultList<VideoCaption>>({
46 defaultExpectedStatus: HttpStatusCode.OK_200
50 delete (options: OverrideCommandOptions & {
51 videoId: string | number
54 const { videoId, language } = options
55 const path = '/api/v1/videos/' + videoId + '/captions/' + language
57 return this.deleteRequest({
62 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204