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 getMyVideoImports (options: OverrideCommandOptions & {
32 const { sort } = options
33 const path = '/api/v1/users/me/videos/imports'
36 if (sort) query['sort'] = sort
38 return this.getRequestBody<ResultList<VideoImport>>({
44 defaultExpectedStatus: HttpStatusCode.OK_200