]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | import { VideoImportCreate } from '../../models/videos' | |
3 | import { makeGetRequest, makeUploadRequest } from '../requests/requests' | |
4 | ||
5 | function getYoutubeVideoUrl () { | |
6 | return 'http://www.youtube.com/watch?v=msX3jv1XdvM' | |
7 | } | |
8 | ||
9 | function getMagnetURI () { | |
10 | // eslint-disable-next-line max-len | |
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 getGoodVideoUrl () { | |
19 | return 'https://download.cpy.re/peertube/good_video.mp4' | |
20 | } | |
21 | ||
22 | function importVideo (url: string, token: string, attributes: VideoImportCreate & { torrentfile?: string }, statusCodeExpected = 200) { | |
23 | const path = '/api/v1/videos/imports' | |
24 | ||
25 | let attaches: any = {} | |
26 | if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile } | |
27 | ||
28 | return makeUploadRequest({ | |
29 | url, | |
30 | path, | |
31 | token, | |
32 | attaches, | |
33 | fields: attributes, | |
34 | statusCodeExpected | |
35 | }) | |
36 | } | |
37 | ||
38 | function getMyVideoImports (url: string, token: string, sort?: string) { | |
39 | const path = '/api/v1/users/me/videos/imports' | |
40 | ||
41 | const query = {} | |
42 | if (sort) query['sort'] = sort | |
43 | ||
44 | return makeGetRequest({ | |
45 | url, | |
46 | query, | |
47 | path, | |
48 | token, | |
49 | statusCodeExpected: 200 | |
50 | }) | |
51 | } | |
52 | ||
53 | // --------------------------------------------------------------------------- | |
54 | ||
55 | export { | |
56 | getBadVideoUrl, | |
57 | getYoutubeVideoUrl, | |
58 | importVideo, | |
59 | getMagnetURI, | |
60 | getMyVideoImports, | |
61 | getGoodVideoUrl | |
62 | } |