diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-17 09:29:23 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-17 09:29:23 +0100 |
commit | bf54587a3e2ad9c2c186828f2a5682b91ee2cc00 (patch) | |
tree | 54b40aaf01bae210632473285c3c7571d51e4f89 /shared/server-commands/videos/imports-command.ts | |
parent | 6b5f72beda96d8b7e4d6329c4001827334de27dd (diff) | |
download | PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.tar.gz PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.tar.zst PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.zip |
shared/ typescript types dir server-commands
Diffstat (limited to 'shared/server-commands/videos/imports-command.ts')
-rw-r--r-- | shared/server-commands/videos/imports-command.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/shared/server-commands/videos/imports-command.ts b/shared/server-commands/videos/imports-command.ts new file mode 100644 index 000000000..e4944694d --- /dev/null +++ b/shared/server-commands/videos/imports-command.ts | |||
@@ -0,0 +1,47 @@ | |||
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 | } | ||