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