import 'mocha'
import { expect } from 'chai'
import { HttpStatusCode, randomInt } from '@shared/core-utils'
-import { getGoodVideoUrl, getMagnetURI, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports'
-import { MyUser, VideoImport, VideoImportState, VideoPrivacy } from '@shared/models'
+import { MyUser, VideoImportState, VideoPrivacy } from '@shared/models'
import {
cleanupTests,
flushAndRunServer,
getMyUserInformation,
- immutableAssign,
+ ImportsCommand,
registerUser,
ServerInfo,
setAccessTokensToServers,
channelId: server.videoChannel.id,
privacy: VideoPrivacy.PUBLIC
}
- await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getGoodVideoUrl() }))
- await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() }))
- await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' as any }))
+ await server.importsCommand.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } })
+ await server.importsCommand.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } })
+ await server.importsCommand.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } })
await waitJobs([ server ])
- const res = await getMyVideoImports(server.url, server.accessToken)
+ const { total, data: videoImports } = await server.importsCommand.getMyVideoImports()
+ expect(total).to.equal(3)
- expect(res.body.total).to.equal(3)
- const videoImports: VideoImport[] = res.body.data
expect(videoImports).to.have.lengthOf(3)
for (const videoImport of videoImports) {
flushAndRunServer,
getMyUserInformation,
immutableAssign,
+ ImportsCommand,
makeGetRequest,
makePostBodyRequest,
makeUploadRequest,
setAccessTokensToServers,
userLogin
} from '@shared/extra-utils'
-import { getGoodVideoUrl, getMagnetURI } from '@shared/extra-utils/videos/video-imports'
import { VideoPrivacy } from '@shared/models'
describe('Test video imports API validator', function () {
before(function () {
baseCorrectParams = {
- targetUrl: getGoodVideoUrl(),
+ targetUrl: ImportsCommand.getGoodVideoUrl(),
name: 'my super name',
category: 5,
licence: 1,
})
let fields = omit(baseCorrectParams, 'targetUrl')
- fields = immutableAssign(fields, { magnetUri: getMagnetURI() })
+ fields = immutableAssign(fields, { magnetUri: ImportsCommand.getMagnetURI() })
await makePostBodyRequest({
url: server.url,
getMyUserInformation,
getMyVideos,
getVideosList,
+ ImportsCommand,
killallServers,
reRunServer,
ServerInfo,
userLogin,
waitJobs
} from '@shared/extra-utils'
-import { getGoodVideoUrl, getMagnetURI, importVideo } from '@shared/extra-utils/videos/video-imports'
import { User, UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'
const expect = chai.expect
this.timeout(15000)
const attributes = {
- targetUrl: getGoodVideoUrl(),
+ targetUrl: ImportsCommand.getGoodVideoUrl(),
name: 'URL import',
channelId: channelOfUserWithoutFlag
}
- await importVideo(servers[0].url, userWithoutFlag, attributes)
+ await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes })
const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(2)
it('Should auto blacklist a video on torrent import', async function () {
const attributes = {
- magnetUri: getMagnetURI(),
+ magnetUri: ImportsCommand.getMagnetURI(),
name: 'Torrent import',
channelId: channelOfUserWithoutFlag
}
- await importVideo(servers[0].url, userWithoutFlag, attributes)
+ await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes })
const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(3)
checkVideoIsPublished,
cleanupTests,
getLastNotification,
+ ImportsCommand,
MockSmtpServer,
prepareNotificationsTest,
ServerInfo,
wait,
waitJobs
} from '@shared/extra-utils'
-import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '@shared/extra-utils/videos/video-imports'
import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models'
const expect = chai.expect
name,
channelId,
privacy: VideoPrivacy.PUBLIC,
- targetUrl: getGoodVideoUrl()
+ targetUrl: ImportsCommand.getGoodVideoUrl()
}
- const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
- const uuid = res.body.video.uuid
+ const { video } = await servers[0].importsCommand.importVideo({ attributes })
await waitJobs(servers)
- await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
+ await checkNewVideoFromSubscription(baseParams, name, video.uuid, 'presence')
})
})
name,
channelId,
privacy: VideoPrivacy.PUBLIC,
- targetUrl: getGoodVideoUrl(),
+ targetUrl: ImportsCommand.getGoodVideoUrl(),
waitTranscoding: true
}
- const res = await importVideo(servers[1].url, servers[1].accessToken, attributes)
- const uuid = res.body.video.uuid
+ const { video } = await servers[1].importsCommand.importVideo({ attributes })
await waitJobs(servers)
- await checkVideoIsPublished(baseParams, name, uuid, 'presence')
+ await checkVideoIsPublished(baseParams, name, video.uuid, 'presence')
})
it('Should send a notification when the scheduled update has been proceeded', async function () {
name,
channelId,
privacy: VideoPrivacy.PRIVATE,
- targetUrl: getBadVideoUrl()
+ targetUrl: ImportsCommand.getBadVideoUrl()
}
- const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
- const uuid = res.body.video.uuid
+ const { video } = await servers[0].importsCommand.importVideo({ attributes })
await waitJobs(servers)
- await checkMyVideoImportIsFinished(baseParams, name, uuid, getBadVideoUrl(), false, 'presence')
+ await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence')
})
it('Should send a notification when the video import succeeded', async function () {
name,
channelId,
privacy: VideoPrivacy.PRIVATE,
- targetUrl: getGoodVideoUrl()
+ targetUrl: ImportsCommand.getGoodVideoUrl()
}
- const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
- const uuid = res.body.video.uuid
+ const { video } = await servers[0].importsCommand.importVideo({ attributes })
await waitJobs(servers)
- await checkMyVideoImportIsFinished(baseParams, name, uuid, getGoodVideoUrl(), true, 'presence')
+ await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence')
})
})
import 'mocha'
import * as chai from 'chai'
import {
+ areHttpImportTestsDisabled,
cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
getVideo,
getVideosList,
immutableAssign,
+ ImportsCommand,
ServerInfo,
setAccessTokensToServers,
- testCaptionFile
-} from '../../../../shared/extra-utils'
-import { areHttpImportTestsDisabled, testImage } from '../../../../shared/extra-utils/miscs/miscs'
-import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
-import {
- getMagnetURI,
- getMyVideoImports,
- getYoutubeHDRVideoUrl,
- getYoutubeVideoUrl,
- importVideo
-} from '../../../../shared/extra-utils/videos/video-imports'
-import { VideoDetails, VideoImport, VideoPrivacy, VideoResolution } from '../../../../shared/models/videos'
+ testCaptionFile,
+ testImage,
+ waitJobs
+} from '@shared/extra-utils'
+import { VideoDetails, VideoPrivacy, VideoResolution } from '@shared/models'
const expect = chai.expect
}
{
- const attributes = immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() })
- const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
- expect(res.body.video.name).to.equal('small video - youtube')
+ const attributes = immutableAssign(baseAttributes, { targetUrl: ImportsCommand.getYoutubeVideoUrl() })
+ const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ expect(video.name).to.equal('small video - youtube')
- expect(res.body.video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`))
- expect(res.body.video.previewPath).to.match(new RegExp(`^/lazy-static/previews/.+.jpg$`))
+ expect(video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`))
+ expect(video.previewPath).to.match(new RegExp(`^/lazy-static/previews/.+.jpg$`))
- await testImage(servers[0].url, 'video_import_thumbnail', res.body.video.thumbnailPath)
- await testImage(servers[0].url, 'video_import_preview', res.body.video.previewPath)
+ await testImage(servers[0].url, 'video_import_thumbnail', video.thumbnailPath)
+ await testImage(servers[0].url, 'video_import_preview', video.previewPath)
- const bodyCaptions = await servers[0].captionsCommand.listVideoCaptions({ videoId: res.body.video.id })
+ const bodyCaptions = await servers[0].captionsCommand.listVideoCaptions({ videoId: video.id })
const videoCaptions = bodyCaptions.data
expect(videoCaptions).to.have.lengthOf(2)
{
const attributes = immutableAssign(baseAttributes, {
- magnetUri: getMagnetURI(),
+ magnetUri: ImportsCommand.getMagnetURI(),
description: 'this is a super torrent description',
tags: [ 'tag_torrent1', 'tag_torrent2' ]
})
- const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
- expect(res.body.video.name).to.equal('super peertube2 video')
+ const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ expect(video.name).to.equal('super peertube2 video')
}
{
description: 'this is a super torrent description',
tags: [ 'tag_torrent1', 'tag_torrent2' ]
})
- const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
- expect(res.body.video.name).to.equal('你好 世界 720p.mp4')
+ const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ expect(video.name).to.equal('你好 世界 720p.mp4')
}
})
})
it('Should list the videos to import in my imports on server 1', async function () {
- const res = await getMyVideoImports(servers[0].url, servers[0].accessToken, '-createdAt')
+ const { total, data: videoImports } = await servers[0].importsCommand.getMyVideoImports({ sort: '-createdAt' })
+ expect(total).to.equal(3)
- expect(res.body.total).to.equal(3)
- const videoImports: VideoImport[] = res.body.data
expect(videoImports).to.have.lengthOf(3)
- expect(videoImports[2].targetUrl).to.equal(getYoutubeVideoUrl())
+ expect(videoImports[2].targetUrl).to.equal(ImportsCommand.getYoutubeVideoUrl())
expect(videoImports[2].magnetUri).to.be.null
expect(videoImports[2].torrentName).to.be.null
expect(videoImports[2].video.name).to.equal('small video - youtube')
expect(videoImports[1].targetUrl).to.be.null
- expect(videoImports[1].magnetUri).to.equal(getMagnetURI())
+ expect(videoImports[1].magnetUri).to.equal(ImportsCommand.getMagnetURI())
expect(videoImports[1].torrentName).to.be.null
expect(videoImports[1].video.name).to.equal('super peertube2 video')
this.timeout(60_000)
const attributes = {
- targetUrl: getYoutubeVideoUrl(),
+ targetUrl: ImportsCommand.getYoutubeVideoUrl(),
channelId: channelIdServer2,
privacy: VideoPrivacy.PUBLIC,
category: 10,
description: 'my super description',
tags: [ 'supertag1', 'supertag2' ]
}
- const res = await importVideo(servers[1].url, servers[1].accessToken, attributes)
- expect(res.body.video.name).to.equal('my super name')
+ const { video } = await servers[1].importsCommand.importVideo({ attributes })
+ expect(video.name).to.equal('my super name')
})
it('Should have the videos listed on the two instances', async function () {
const attributes = {
name: 'transcoded video',
- magnetUri: getMagnetURI(),
+ magnetUri: ImportsCommand.getMagnetURI(),
channelId: channelIdServer2,
privacy: VideoPrivacy.PUBLIC
}
- const res = await importVideo(servers[1].url, servers[1].accessToken, attributes)
- const videoUUID = res.body.video.uuid
+ const { video } = await servers[1].importsCommand.importVideo({ attributes })
+ const videoUUID = video.uuid
await waitJobs(servers)
const attributes = {
name: 'hdr video',
- targetUrl: getYoutubeHDRVideoUrl(),
+ targetUrl: ImportsCommand.getYoutubeHDRVideoUrl(),
channelId: channelIdServer1,
privacy: VideoPrivacy.PUBLIC
}
- const res1 = await importVideo(servers[0].url, servers[0].accessToken, attributes)
- const videoUUID = res1.body.video.uuid
+ const { video: videoImported } = await servers[0].importsCommand.importVideo({ attributes })
+ const videoUUID = videoImported.uuid
await waitJobs(servers)
getLocalIdByUUID,
getVideo,
getVideosList,
+ ImportsCommand,
removeVideo,
ServerInfo,
setAccessTokensToServers,
userLogin,
waitJobs
} from '../../../shared/extra-utils'
-import { getYoutubeVideoUrl } from '../../../shared/extra-utils/videos/video-imports'
describe('Test CLI wrapper', function () {
let server: ServerInfo
this.timeout(60000)
- const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel`
+ const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} --channel-name user_channel`
await cliCommand.execWithEnv(`${cmd} import ${params}`)
})
this.timeout(60000)
- const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support`
+ const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} ` +
+ `--channel-name user_channel --video-name toto --nsfw --support support`
await cliCommand.execWithEnv(`${cmd} import ${params}`)
await waitJobs([ server ])
getVideosListPagination,
getVideoThreadComments,
getVideoWithToken,
+ ImportsCommand,
makeRawRequest,
PluginsCommand,
registerUser,
waitJobs,
waitUntilLog
} from '@shared/extra-utils'
-import { getGoodVideoUrl, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports'
-import {
- VideoCommentThreadTree,
- VideoDetails,
- VideoImport,
- VideoImportState,
- VideoPlaylist,
- VideoPlaylistPrivacy,
- VideoPrivacy
-} from '@shared/models'
+import { VideoCommentThreadTree, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
const expect = chai.expect
})
it('Should run filter:api.video.pre-import-url.accept.result', async function () {
- const baseAttributes = {
+ const attributes = {
name: 'normal title',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id,
- targetUrl: getGoodVideoUrl() + 'bad'
+ targetUrl: ImportsCommand.getGoodVideoUrl() + 'bad'
}
- await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, HttpStatusCode.FORBIDDEN_403)
+ await servers[0].importsCommand.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.video.pre-import-torrent.accept.result', async function () {
- const baseAttributes = {
+ const attributes = {
name: 'bad torrent',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id,
torrentfile: 'video-720p.torrent' as any
}
- await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, HttpStatusCode.FORBIDDEN_403)
+ await servers[0].importsCommand.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.video.post-import-url.accept.result', async function () {
let videoImportId: number
{
- const baseAttributes = {
+ const attributes = {
name: 'title with bad word',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id,
- targetUrl: getGoodVideoUrl()
+ targetUrl: ImportsCommand.getGoodVideoUrl()
}
- const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes)
- videoImportId = res.body.id
+ const body = await servers[0].importsCommand.importVideo({ attributes })
+ videoImportId = body.id
}
await waitJobs(servers)
{
- const res = await getMyVideoImports(servers[0].url, servers[0].accessToken)
- const videoImports = res.body.data as VideoImport[]
+ const body = await servers[0].importsCommand.getMyVideoImports()
+ const videoImports = body.data
const videoImport = videoImports.find(i => i.id === videoImportId)
let videoImportId: number
{
- const baseAttributes = {
+ const attributes = {
name: 'title with bad word',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id,
torrentfile: 'video-720p.torrent' as any
}
- const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes)
- videoImportId = res.body.id
+ const body = await servers[0].importsCommand.importVideo({ attributes })
+ videoImportId = body.id
}
await waitJobs(servers)
{
- const res = await getMyVideoImports(servers[0].url, servers[0].accessToken)
- const videoImports = res.body.data as VideoImport[]
+ const { data: videoImports } = await servers[0].importsCommand.getMyVideoImports()
const videoImport = videoImports.find(i => i.id === videoImportId)
describe('Should run filter:video.auto-blacklist.result', function () {
- async function checkIsBlacklisted (oldRes: any, value: boolean) {
- const videoId = oldRes.body.video.uuid
-
- const res = await getVideoWithToken(servers[0].url, servers[0].accessToken, videoId)
+ async function checkIsBlacklisted (id: number | string, value: boolean) {
+ const res = await getVideoWithToken(servers[0].url, servers[0].accessToken, id)
const video: VideoDetails = res.body
expect(video.blacklisted).to.equal(value)
}
it('Should blacklist on upload', async function () {
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video please blacklist me' })
- await checkIsBlacklisted(res, true)
+ await checkIsBlacklisted(res.body.video.uuid, true)
})
it('Should blacklist on import', async function () {
const attributes = {
name: 'video please blacklist me',
- targetUrl: getGoodVideoUrl(),
+ targetUrl: ImportsCommand.getGoodVideoUrl(),
channelId: servers[0].videoChannel.id
}
- const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
- await checkIsBlacklisted(res, true)
+ const body = await servers[0].importsCommand.importVideo({ attributes })
+ await checkIsBlacklisted(body.video.uuid, true)
})
it('Should blacklist on update', async function () {
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
const videoId = res.body.video.uuid
- await checkIsBlacklisted(res, false)
+ await checkIsBlacklisted(videoId, false)
await updateVideo(servers[0].url, servers[0].accessToken, videoId, { name: 'please blacklist me' })
- await checkIsBlacklisted(res, true)
+ await checkIsBlacklisted(videoId, true)
})
it('Should blacklist on remote upload', async function () {
const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'remote please blacklist me' })
await waitJobs(servers)
- await checkIsBlacklisted(res, true)
+ await checkIsBlacklisted(res.body.video.uuid, true)
})
it('Should blacklist on remote update', async function () {
await waitJobs(servers)
const videoId = res.body.video.uuid
- await checkIsBlacklisted(res, false)
+ await checkIsBlacklisted(videoId, false)
await updateVideo(servers[1].url, servers[1].accessToken, videoId, { name: 'please blacklist me' })
await waitJobs(servers)
- await checkIsBlacklisted(res, true)
+ await checkIsBlacklisted(videoId, true)
})
})
import { SearchCommand } from '../search'
import { SocketIOCommand } from '../socket'
import { AccountsCommand, BlocklistCommand, SubscriptionsCommand } from '../users'
-import { BlacklistCommand, CaptionsCommand, ChangeOwnershipCommand, HistoryCommand, LiveCommand, PlaylistsCommand, ServicesCommand } from '../videos'
+import {
+ BlacklistCommand,
+ CaptionsCommand,
+ ChangeOwnershipCommand,
+ HistoryCommand,
+ ImportsCommand,
+ LiveCommand,
+ PlaylistsCommand,
+ ServicesCommand
+} from '../videos'
import { ConfigCommand } from './config-command'
import { ContactFormCommand } from './contact-form-command'
import { DebugCommand } from './debug-command'
changeOwnershipCommand?: ChangeOwnershipCommand
playlistsCommand?: PlaylistsCommand
historyCommand?: HistoryCommand
+ importsCommand?: ImportsCommand
}
function parallelTests () {
server.changeOwnershipCommand = new ChangeOwnershipCommand(server)
server.playlistsCommand = new PlaylistsCommand(server)
server.historyCommand = new HistoryCommand(server)
+ server.importsCommand = new ImportsCommand(server)
res(server)
})
--- /dev/null
+
+import { ResultList } from '@shared/models'
+import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { VideoImport, VideoImportCreate } from '../../models/videos'
+import { unwrapBody } from '../requests'
+import { AbstractCommand, OverrideCommandOptions } from '../shared'
+
+export class ImportsCommand extends AbstractCommand {
+
+ static getYoutubeVideoUrl () {
+ return 'https://www.youtube.com/watch?v=msX3jv1XdvM'
+ }
+
+ static getYoutubeHDRVideoUrl () {
+ /**
+ * The video is used to check format-selection correctness wrt. HDR,
+ * which brings its own set of oddities outside of a MediaSource.
+ * FIXME: refactor once HDR is supported at playback
+ *
+ * The video needs to have the following format_ids:
+ * (which you can check by using `youtube-dl <url> -F`):
+ * - 303 (1080p webm vp9)
+ * - 299 (1080p mp4 avc1)
+ * - 335 (1080p webm vp9.2 HDR)
+ *
+ * 15 jan. 2021: TEST VIDEO NOT CURRENTLY PROVIDING
+ * - 400 (1080p mp4 av01)
+ * - 315 (2160p webm vp9 HDR)
+ * - 337 (2160p webm vp9.2 HDR)
+ * - 401 (2160p mp4 av01 HDR)
+ */
+ return 'https://www.youtube.com/watch?v=qR5vOXbZsI4'
+ }
+
+ static getMagnetURI () {
+ // eslint-disable-next-line max-len
+ 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'
+ }
+
+ static getBadVideoUrl () {
+ return 'https://download.cpy.re/peertube/bad_video.mp4'
+ }
+
+ static getGoodVideoUrl () {
+ return 'https://download.cpy.re/peertube/good_video.mp4'
+ }
+
+ importVideo (options: OverrideCommandOptions & {
+ attributes: VideoImportCreate & { torrentfile?: string }
+ }) {
+ const { attributes } = options
+ const path = '/api/v1/videos/imports'
+
+ let attaches: any = {}
+ if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile }
+
+ return unwrapBody<VideoImport>(this.postUploadRequest({
+ ...options,
+
+ path,
+ attaches,
+ fields: options.attributes,
+ implicitToken: true,
+ defaultExpectedStatus: HttpStatusCode.OK_200
+ }))
+ }
+
+ getMyVideoImports (options: OverrideCommandOptions & {
+ sort?: string
+ } = {}) {
+ const { sort } = options
+ const path = '/api/v1/users/me/videos/imports'
+
+ const query = {}
+ if (sort) query['sort'] = sort
+
+ return this.getRequestBody<ResultList<VideoImport>>({
+ ...options,
+
+ path,
+ query: { sort },
+ implicitToken: true,
+ defaultExpectedStatus: HttpStatusCode.OK_200
+ })
+ }
+}
export * from './captions-command'
export * from './change-ownership-command'
export * from './history-command'
+export * from './imports-command'
export * from './live-command'
export * from './live'
export * from './playlists-command'
export * from './services-command'
export * from './video-channels'
export * from './video-comments'
-export * from './video-imports'
export * from './video-streaming-playlists'
export * from './videos'
+++ /dev/null
-
-import { VideoImportCreate } from '../../models/videos'
-import { makeGetRequest, makeUploadRequest } from '../requests/requests'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
-
-function getYoutubeVideoUrl () {
- return 'https://www.youtube.com/watch?v=msX3jv1XdvM'
-}
-
-function getYoutubeHDRVideoUrl () {
- /**
- * The video is used to check format-selection correctness wrt. HDR,
- * which brings its own set of oddities outside of a MediaSource.
- * FIXME: refactor once HDR is supported at playback
- *
- * The video needs to have the following format_ids:
- * (which you can check by using `youtube-dl <url> -F`):
- * - 303 (1080p webm vp9)
- * - 299 (1080p mp4 avc1)
- * - 335 (1080p webm vp9.2 HDR)
- *
- * 15 jan. 2021: TEST VIDEO NOT CURRENTLY PROVIDING
- * - 400 (1080p mp4 av01)
- * - 315 (2160p webm vp9 HDR)
- * - 337 (2160p webm vp9.2 HDR)
- * - 401 (2160p mp4 av01 HDR)
- */
- return 'https://www.youtube.com/watch?v=qR5vOXbZsI4'
-}
-
-function getMagnetURI () {
- // eslint-disable-next-line max-len
- 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'
-}
-
-function getBadVideoUrl () {
- return 'https://download.cpy.re/peertube/bad_video.mp4'
-}
-
-function getGoodVideoUrl () {
- return 'https://download.cpy.re/peertube/good_video.mp4'
-}
-
-function importVideo (
- url: string,
- token: string,
- attributes: VideoImportCreate & { torrentfile?: string },
- statusCodeExpected = HttpStatusCode.OK_200
-) {
- 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
- })
-}
-
-function getMyVideoImports (url: string, token: string, sort?: string) {
- const path = '/api/v1/users/me/videos/imports'
-
- const query = {}
- if (sort) query['sort'] = sort
-
- return makeGetRequest({
- url,
- query,
- path,
- token,
- statusCodeExpected: HttpStatusCode.OK_200
- })
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- getBadVideoUrl,
- getYoutubeVideoUrl,
- getYoutubeHDRVideoUrl,
- importVideo,
- getMagnetURI,
- getMyVideoImports,
- getGoodVideoUrl
-}