diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-15 15:26:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:25:52 +0200 |
commit | 94565d52bb2883e09f16d1363170ac9c0dccb7a1 (patch) | |
tree | 3dcd20cd7b5a5cca80bce32b655cdbfaddf7aa59 /shared/extra-utils/videos/video-imports.ts | |
parent | 4ee7a4c9ac9280cda930a281c2d5a9a4c409cc14 (diff) | |
download | PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.gz PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.zst PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.zip |
Shared utils -> extra-utils
Because they need dev dependencies
Diffstat (limited to 'shared/extra-utils/videos/video-imports.ts')
-rw-r--r-- | shared/extra-utils/videos/video-imports.ts | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/shared/extra-utils/videos/video-imports.ts b/shared/extra-utils/videos/video-imports.ts new file mode 100644 index 000000000..ec77cdcda --- /dev/null +++ b/shared/extra-utils/videos/video-imports.ts | |||
@@ -0,0 +1,57 @@ | |||
1 | |||
2 | import { VideoImportCreate } from '../../models/videos' | ||
3 | import { makeGetRequest, makeUploadRequest } from '../requests/requests' | ||
4 | |||
5 | function getYoutubeVideoUrl () { | ||
6 | return 'https://youtu.be/msX3jv1XdvM' | ||
7 | } | ||
8 | |||
9 | function getMagnetURI () { | ||
10 | // tslint:disable:max-line-length | ||
11 | 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' | ||
12 | } | ||
13 | |||
14 | function getBadVideoUrl () { | ||
15 | return 'https://download.cpy.re/peertube/bad_video.mp4' | ||
16 | } | ||
17 | |||
18 | function importVideo (url: string, token: string, attributes: VideoImportCreate) { | ||
19 | const path = '/api/v1/videos/imports' | ||
20 | |||
21 | let attaches: any = {} | ||
22 | if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile } | ||
23 | |||
24 | return makeUploadRequest({ | ||
25 | url, | ||
26 | path, | ||
27 | token, | ||
28 | attaches, | ||
29 | fields: attributes, | ||
30 | statusCodeExpected: 200 | ||
31 | }) | ||
32 | } | ||
33 | |||
34 | function getMyVideoImports (url: string, token: string, sort?: string) { | ||
35 | const path = '/api/v1/users/me/videos/imports' | ||
36 | |||
37 | const query = {} | ||
38 | if (sort) query['sort'] = sort | ||
39 | |||
40 | return makeGetRequest({ | ||
41 | url, | ||
42 | query, | ||
43 | path, | ||
44 | token, | ||
45 | statusCodeExpected: 200 | ||
46 | }) | ||
47 | } | ||
48 | |||
49 | // --------------------------------------------------------------------------- | ||
50 | |||
51 | export { | ||
52 | getBadVideoUrl, | ||
53 | getYoutubeVideoUrl, | ||
54 | importVideo, | ||
55 | getMagnetURI, | ||
56 | getMyVideoImports | ||
57 | } | ||