+ it('Should import videos on server 1', async function () {
+ this.timeout(60_000)
+
+ const baseAttributes = {
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC
+ }
+
+ {
+ const attributes = { ...baseAttributes, targetUrl: FIXTURE_URLS.youtube }
+ const { video } = await servers[0].imports.importVideo({ attributes })
+ expect(video.name).to.equal('small video - youtube')
+
+ {
+ expect(video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`))
+ expect(video.previewPath).to.match(new RegExp(`^/lazy-static/previews/.+.jpg$`))
+
+ const suffix = mode === 'yt-dlp'
+ ? '_yt_dlp'
+ : ''
+
+ await testImage(servers[0].url, 'video_import_thumbnail' + suffix, video.thumbnailPath)
+ await testImage(servers[0].url, 'video_import_preview' + suffix, video.previewPath)
+ }
+
+ const bodyCaptions = await servers[0].captions.list({ videoId: video.id })
+ const videoCaptions = bodyCaptions.data
+ expect(videoCaptions).to.have.lengthOf(2)
+
+ {
+ const enCaption = videoCaptions.find(caption => caption.language.id === 'en')
+ expect(enCaption).to.exist
+ expect(enCaption.language.label).to.equal('English')
+ expect(enCaption.captionPath).to.match(new RegExp(`^/lazy-static/video-captions/.+-en.vtt$`))
+
+ const regex = `WEBVTT[ \n]+Kind: captions[ \n]+` +
+ `(Language: en[ \n]+)?` +
+ `00:00:01.600 --> 00:00:04.200( position:\\d+% line:\\d+%)?[ \n]+English \\(US\\)[ \n]+` +
+ `00:00:05.900 --> 00:00:07.999( position:\\d+% line:\\d+%)?[ \n]+This is a subtitle in American English[ \n]+` +
+ `00:00:10.000 --> 00:00:14.000( position:\\d+% line:\\d+%)?[ \n]+Adding subtitles is very easy to do`
+ await testCaptionFile(servers[0].url, enCaption.captionPath, new RegExp(regex))
+ }
+
+ {
+ const frCaption = videoCaptions.find(caption => caption.language.id === 'fr')
+ expect(frCaption).to.exist
+ expect(frCaption.language.label).to.equal('French')
+ expect(frCaption.captionPath).to.match(new RegExp(`^/lazy-static/video-captions/.+-fr.vtt`))
+
+ const regex = `WEBVTT[ \n]+Kind: captions[ \n]+` +
+ `(Language: fr[ \n]+)?` +
+ `00:00:01.600 --> 00:00:04.200( position:\\d+% line:\\d+%)?[ \n]+Français \\(FR\\)[ \n]+` +
+ `00:00:05.900 --> 00:00:07.999( position:\\d+% line:\\d+%)?[ \n]+C'est un sous-titre français[ \n]+` +
+ `00:00:10.000 --> 00:00:14.000( position:\\d+% line:\\d+%)?[ \n]+Ajouter un sous-titre est vraiment facile`
+
+ await testCaptionFile(servers[0].url, frCaption.captionPath, new RegExp(regex))
+ }
+ }
+
+ {
+ const attributes = {
+ ...baseAttributes,
+ magnetUri: FIXTURE_URLS.magnet,
+ description: 'this is a super torrent description',
+ tags: [ 'tag_torrent1', 'tag_torrent2' ]
+ }
+ const { video } = await servers[0].imports.importVideo({ attributes })
+ expect(video.name).to.equal('super peertube2 video')
+ }
+
+ {
+ const attributes = {
+ ...baseAttributes,
+ torrentfile: 'video-720p.torrent' as any,
+ description: 'this is a super torrent description',
+ tags: [ 'tag_torrent1', 'tag_torrent2' ]
+ }
+ const { video } = await servers[0].imports.importVideo({ attributes })
+ expect(video.name).to.equal('你好 世界 720p.mp4')
+ }
+ })