aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/videos/video-imports.ts
blob: fa2f13b5e16359dbeee5dac5c15a8730131fa66d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { VideoImportCreate } from '../../../../shared/models/videos'
import { makeGetRequest, makePostBodyRequest, makeUploadRequest } from '..'

function getYoutubeVideoUrl () {
  return 'https://youtu.be/msX3jv1XdvM'
}

function getMagnetURI () {
  // tslint:disable:max-line-length
  return 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Ftorrents%2F2b8dbe74-9548-4f6f-a8da-986aed9e5e45-240.torrent&xt=urn:btih:52bf3729e5859390a8751495196b5674a55c99f3&dn=60fps_small&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%2F2b8dbe74-9548-4f6f-a8da-986aed9e5e45-240.mp4'
}

function importVideo (url: string, token: string, attributes: VideoImportCreate) {
  const path = '/api/v1/videos/imports'

  let attaches: any = {}
  if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile }

  return makeUploadRequest({
    url,
    path,
    token,
    attaches,
    fields: attributes,
    statusCodeExpected: 200
  })
}

function getMyVideoImports (url: string, token: string) {
  const path = '/api/v1/users/me/videos/imports'

  return makeGetRequest({
    url,
    path,
    token,
    statusCodeExpected: 200
  })
}

// ---------------------------------------------------------------------------

export {
  getYoutubeVideoUrl,
  importVideo,
  getMagnetURI,
  getMyVideoImports
}