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