]>
Commit | Line | Data |
---|---|---|
6910f20f C |
1 | |
2 | import { ResultList } from '@shared/models' | |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | |
4 | import { VideoImport, VideoImportCreate } from '../../models/videos' | |
5 | import { unwrapBody } from '../requests' | |
6 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | |
7 | ||
8 | export class ImportsCommand extends AbstractCommand { | |
9 | ||
6910f20f C |
10 | importVideo (options: OverrideCommandOptions & { |
11 | attributes: VideoImportCreate & { torrentfile?: string } | |
12 | }) { | |
13 | const { attributes } = options | |
14 | const path = '/api/v1/videos/imports' | |
15 | ||
16 | let attaches: any = {} | |
17 | if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile } | |
18 | ||
19 | return unwrapBody<VideoImport>(this.postUploadRequest({ | |
20 | ...options, | |
21 | ||
22 | path, | |
23 | attaches, | |
24 | fields: options.attributes, | |
25 | implicitToken: true, | |
26 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
27 | })) | |
28 | } | |
29 | ||
30 | getMyVideoImports (options: OverrideCommandOptions & { | |
31 | sort?: string | |
32 | } = {}) { | |
33 | const { sort } = options | |
34 | const path = '/api/v1/users/me/videos/imports' | |
35 | ||
36 | const query = {} | |
37 | if (sort) query['sort'] = sort | |
38 | ||
39 | return this.getRequestBody<ResultList<VideoImport>>({ | |
40 | ...options, | |
41 | ||
42 | path, | |
43 | query: { sort }, | |
44 | implicitToken: true, | |
45 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
46 | }) | |
47 | } | |
48 | } |