diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /shared/extra-utils/videos/imports-command.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'shared/extra-utils/videos/imports-command.ts')
-rw-r--r-- | shared/extra-utils/videos/imports-command.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/shared/extra-utils/videos/imports-command.ts b/shared/extra-utils/videos/imports-command.ts new file mode 100644 index 000000000..e4944694d --- /dev/null +++ b/shared/extra-utils/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 | } | ||