diff options
Diffstat (limited to 'shared/utils/videos/video-imports.ts')
-rw-r--r-- | shared/utils/videos/video-imports.ts | 52 |
1 files changed, 52 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..3fa49b432 --- /dev/null +++ b/shared/utils/videos/video-imports.ts | |||
@@ -0,0 +1,52 @@ | |||
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 importVideo (url: string, token: string, attributes: VideoImportCreate) { | ||
15 | const path = '/api/v1/videos/imports' | ||
16 | |||
17 | let attaches: any = {} | ||
18 | if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile } | ||
19 | |||
20 | return makeUploadRequest({ | ||
21 | url, | ||
22 | path, | ||
23 | token, | ||
24 | attaches, | ||
25 | fields: attributes, | ||
26 | statusCodeExpected: 200 | ||
27 | }) | ||
28 | } | ||
29 | |||
30 | function getMyVideoImports (url: string, token: string, sort?: string) { | ||
31 | const path = '/api/v1/users/me/videos/imports' | ||
32 | |||
33 | const query = {} | ||
34 | if (sort) query['sort'] = sort | ||
35 | |||
36 | return makeGetRequest({ | ||
37 | url, | ||
38 | query, | ||
39 | path, | ||
40 | token, | ||
41 | statusCodeExpected: 200 | ||
42 | }) | ||
43 | } | ||
44 | |||
45 | // --------------------------------------------------------------------------- | ||
46 | |||
47 | export { | ||
48 | getYoutubeVideoUrl, | ||
49 | importVideo, | ||
50 | getMagnetURI, | ||
51 | getMyVideoImports | ||
52 | } | ||