2 import { HttpStatusCode, ResultList } from '@shared/models'
3 import { VideoImport, VideoImportCreate } from '../../models/videos'
4 import { unwrapBody } from '../requests'
5 import { AbstractCommand, OverrideCommandOptions } from '../shared'
7 export class ImportsCommand extends AbstractCommand {
9 importVideo (options: OverrideCommandOptions & {
10 attributes: VideoImportCreate & { torrentfile?: string }
12 const { attributes } = options
13 const path = '/api/v1/videos/imports'
15 let attaches: any = {}
16 if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile }
18 return unwrapBody<VideoImport>(this.postUploadRequest({
23 fields: options.attributes,
25 defaultExpectedStatus: HttpStatusCode.OK_200
29 delete (options: OverrideCommandOptions & {
32 const path = '/api/v1/videos/imports/' + options.importId
34 return this.deleteRequest({
39 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
43 cancel (options: OverrideCommandOptions & {
46 const path = '/api/v1/videos/imports/' + options.importId + '/cancel'
48 return this.postBodyRequest({
53 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
57 getMyVideoImports (options: OverrideCommandOptions & {
60 videoChannelSyncId?: number
63 const { sort, targetUrl, videoChannelSyncId, search } = options
64 const path = '/api/v1/users/me/videos/imports'
66 return this.getRequestBody<ResultList<VideoImport>>({
70 query: { sort, targetUrl, videoChannelSyncId, search },
72 defaultExpectedStatus: HttpStatusCode.OK_200