video-imports.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { VideoImportCreate } from '../../models/videos'
  2. import { makeGetRequest, makeUploadRequest } from '../requests/requests'
  3. function getYoutubeVideoUrl () {
  4. return 'https://youtu.be/msX3jv1XdvM'
  5. }
  6. function getMagnetURI () {
  7. // tslint:disable:max-line-length
  8. 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'
  9. }
  10. function getBadVideoUrl () {
  11. return 'https://download.cpy.re/peertube/bad_video.mp4'
  12. }
  13. function importVideo (url: string, token: string, attributes: VideoImportCreate) {
  14. const path = '/api/v1/videos/imports'
  15. let attaches: any = {}
  16. if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile }
  17. return makeUploadRequest({
  18. url,
  19. path,
  20. token,
  21. attaches,
  22. fields: attributes,
  23. statusCodeExpected: 200
  24. })
  25. }
  26. function getMyVideoImports (url: string, token: string, sort?: string) {
  27. const path = '/api/v1/users/me/videos/imports'
  28. const query = {}
  29. if (sort) query['sort'] = sort
  30. return makeGetRequest({
  31. url,
  32. query,
  33. path,
  34. token,
  35. statusCodeExpected: 200
  36. })
  37. }
  38. // ---------------------------------------------------------------------------
  39. export {
  40. getBadVideoUrl,
  41. getYoutubeVideoUrl,
  42. importVideo,
  43. getMagnetURI,
  44. getMyVideoImports
  45. }