diff options
Diffstat (limited to 'shared/utils/videos/video-imports.ts')
-rw-r--r-- | shared/utils/videos/video-imports.ts | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/shared/utils/videos/video-imports.ts b/shared/utils/videos/video-imports.ts new file mode 100644 index 000000000..59dfd481a --- /dev/null +++ b/shared/utils/videos/video-imports.ts | |||
@@ -0,0 +1,51 @@ | |||
1 | import { VideoImportCreate } from '../../../../shared/models/videos' | ||
2 | import { makeGetRequest, makeUploadRequest } from '..' | ||
3 | |||
4 | function getYoutubeVideoUrl () { | ||
5 | return 'https://youtu.be/msX3jv1XdvM' | ||
6 | } | ||
7 | |||
8 | function getMagnetURI () { | ||
9 | // tslint:disable:max-line-length | ||
10 | return 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4' | ||
11 | } | ||
12 | |||
13 | function importVideo (url: string, token: string, attributes: VideoImportCreate) { | ||
14 | const path = '/api/v1/videos/imports' | ||
15 | |||
16 | let attaches: any = {} | ||
17 | if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile } | ||
18 | |||
19 | return makeUploadRequest({ | ||
20 | url, | ||
21 | path, | ||
22 | token, | ||
23 | attaches, | ||
24 | fields: attributes, | ||
25 | statusCodeExpected: 200 | ||
26 | }) | ||
27 | } | ||
28 | |||
29 | function getMyVideoImports (url: string, token: string, sort?: string) { | ||
30 | const path = '/api/v1/users/me/videos/imports' | ||
31 | |||
32 | const query = {} | ||
33 | if (sort) query['sort'] = sort | ||
34 | |||
35 | return makeGetRequest({ | ||
36 | url, | ||
37 | query, | ||
38 | path, | ||
39 | token, | ||
40 | statusCodeExpected: 200 | ||
41 | }) | ||
42 | } | ||
43 | |||
44 | // --------------------------------------------------------------------------- | ||
45 | |||
46 | export { | ||
47 | getYoutubeVideoUrl, | ||
48 | importVideo, | ||
49 | getMagnetURI, | ||
50 | getMyVideoImports | ||
51 | } | ||