+ it('Should import a video that will be transcoded', async function () {
+ this.timeout(240_000)
+
+ const attributes = {
+ name: 'transcoded video',
+ magnetUri: FIXTURE_URLS.magnet,
+ channelId: servers[1].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC
+ }
+ const { video } = await servers[1].imports.importVideo({ attributes })
+ const videoUUID = video.uuid
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const video = await server.videos.get({ id: videoUUID })
+
+ expect(video.name).to.equal('transcoded video')
+ expect(video.files).to.have.lengthOf(4)
+ }
+ })
+
+ it('Should import no HDR version on a HDR video', async function () {
+ this.timeout(300_000)
+
+ const config: DeepPartial<CustomConfig> = {
+ transcoding: {
+ enabled: true,
+ resolutions: {
+ '0p': false,
+ '144p': true,
+ '240p': true,
+ '360p': false,
+ '480p': false,
+ '720p': false,
+ '1080p': false, // the resulting resolution shouldn't be higher than this, and not vp9.2/av01
+ '1440p': false,
+ '2160p': false
+ },
+ webtorrent: { enabled: true },
+ hls: { enabled: false }
+ }
+ }
+ await servers[0].config.updateExistingSubConfig({ newConfig: config })
+
+ const attributes = {
+ name: 'hdr video',
+ targetUrl: FIXTURE_URLS.youtubeHDR,
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC
+ }
+ const { video: videoImported } = await servers[0].imports.importVideo({ attributes })
+ const videoUUID = videoImported.uuid
+
+ await waitJobs(servers)
+
+ // test resolution
+ const video = await servers[0].videos.get({ id: videoUUID })
+ expect(video.name).to.equal('hdr video')
+ const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id }))
+ expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_240P)
+ })
+
+ it('Should not import resolution higher than enabled transcoding resolution', async function () {
+ this.timeout(300_000)
+
+ const config: DeepPartial<CustomConfig> = {
+ transcoding: {
+ enabled: true,
+ resolutions: {
+ '0p': false,
+ '144p': true,
+ '240p': false,
+ '360p': false,
+ '480p': false,
+ '720p': false,
+ '1080p': false,
+ '1440p': false,
+ '2160p': false
+ },
+ alwaysTranscodeOriginalResolution: false
+ }
+ }
+ await servers[0].config.updateExistingSubConfig({ newConfig: config })
+
+ const attributes = {
+ name: 'small resolution video',
+ targetUrl: FIXTURE_URLS.youtube,
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC
+ }
+ const { video: videoImported } = await servers[0].imports.importVideo({ attributes })
+ const videoUUID = videoImported.uuid
+
+ await waitJobs(servers)
+
+ // test resolution
+ const video = await servers[0].videos.get({ id: videoUUID })
+ expect(video.name).to.equal('small resolution video')
+ expect(video.files).to.have.lengthOf(1)
+ expect(video.files[0].resolution.id).to.equal(144)
+ })
+
+ it('Should import resolution higher than enabled transcoding resolution', async function () {
+ this.timeout(300_000)
+
+ const config: DeepPartial<CustomConfig> = {
+ transcoding: {
+ alwaysTranscodeOriginalResolution: true
+ }
+ }
+ await servers[0].config.updateExistingSubConfig({ newConfig: config })
+
+ const attributes = {
+ name: 'bigger resolution video',
+ targetUrl: FIXTURE_URLS.youtube,
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC
+ }
+ const { video: videoImported } = await servers[0].imports.importVideo({ attributes })
+ const videoUUID = videoImported.uuid
+
+ await waitJobs(servers)
+
+ // test resolution
+ const video = await servers[0].videos.get({ id: videoUUID })
+ expect(video.name).to.equal('bigger resolution video')
+
+ expect(video.files).to.have.lengthOf(2)
+ expect(video.files.find(f => f.resolution.id === 240)).to.exist
+ expect(video.files.find(f => f.resolution.id === 144)).to.exist
+ })
+
+ it('Should import a peertube video', async function () {
+ this.timeout(120_000)
+
+ const toTest = [ FIXTURE_URLS.peertube_long ]
+
+ // TODO: include peertube_short when https://github.com/ytdl-org/youtube-dl/pull/29475 is merged
+ if (mode === 'yt-dlp') {
+ toTest.push(FIXTURE_URLS.peertube_short)
+ }
+
+ for (const targetUrl of toTest) {
+ await servers[0].config.disableTranscoding()
+
+ const attributes = {
+ targetUrl,
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC
+ }
+ const { video } = await servers[0].imports.importVideo({ attributes })
+ const videoUUID = video.uuid
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const video = await server.videos.get({ id: videoUUID })
+
+ expect(video.name).to.equal('E2E tests')
+ }
+ }
+ })