2 import { HttpStatusCode } from '@shared/models'
3 import { ResultList } from '@shared/models'
4 import { VideoImport, VideoImportCreate } from '../../models/videos'
5 import { unwrapBody } from '../requests'
6 import { AbstractCommand, OverrideCommandOptions } from '../shared'
8 export class ImportsCommand extends AbstractCommand {
10 importVideo (options: OverrideCommandOptions & {
11 attributes: VideoImportCreate & { torrentfile?: string }
13 const { attributes } = options
14 const path = '/api/v1/videos/imports'
16 let attaches: any = {}
17 if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile }
19 return unwrapBody<VideoImport>(this.postUploadRequest({
24 fields: options.attributes,
26 defaultExpectedStatus: HttpStatusCode.OK_200
30 getMyVideoImports (options: OverrideCommandOptions & {
33 const { sort } = options
34 const path = '/api/v1/users/me/videos/imports'
37 if (sort) query['sort'] = sort
39 return this.getRequestBody<ResultList<VideoImport>>({
45 defaultExpectedStatus: HttpStatusCode.OK_200