diff options
-rw-r--r-- | server/controllers/api/videos/import.ts | 6 | ||||
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 26 | ||||
-rw-r--r-- | shared/extra-utils/miscs/tests.ts | 3 |
3 files changed, 34 insertions, 1 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 39fc57788..5f90e4308 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -3,6 +3,7 @@ import { move, readFile } from 'fs-extra' | |||
3 | import { decode } from 'magnet-uri' | 3 | import { decode } from 'magnet-uri' |
4 | import parseTorrent, { Instance } from 'parse-torrent' | 4 | import parseTorrent, { Instance } from 'parse-torrent' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { isVideoFileExtnameValid } from '@server/helpers/custom-validators/videos' | ||
6 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 7 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
7 | import { setVideoTags } from '@server/lib/video' | 8 | import { setVideoTags } from '@server/lib/video' |
8 | import { FilteredModelAttributes } from '@server/types' | 9 | import { FilteredModelAttributes } from '@server/types' |
@@ -185,11 +186,14 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) | |||
185 | // Get video subtitles | 186 | // Get video subtitles |
186 | await processYoutubeSubtitles(youtubeDL, targetUrl, video.id) | 187 | await processYoutubeSubtitles(youtubeDL, targetUrl, video.id) |
187 | 188 | ||
189 | let fileExt = `.${youtubeDLInfo.ext}` | ||
190 | if (!isVideoFileExtnameValid(fileExt)) fileExt = '.mp4' | ||
191 | |||
188 | // Create job to import the video | 192 | // Create job to import the video |
189 | const payload = { | 193 | const payload = { |
190 | type: 'youtube-dl' as 'youtube-dl', | 194 | type: 'youtube-dl' as 'youtube-dl', |
191 | videoImportId: videoImport.id, | 195 | videoImportId: videoImport.id, |
192 | fileExt: `.${youtubeDLInfo.ext || 'mp4'}` | 196 | fileExt |
193 | } | 197 | } |
194 | await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }) | 198 | await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }) |
195 | 199 | ||
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index 2eac130d2..108688651 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -336,6 +336,32 @@ Ajouter un sous-titre est vraiment facile`) | |||
336 | expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P) | 336 | expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P) |
337 | }) | 337 | }) |
338 | 338 | ||
339 | it('Should import a peertube video', async function () { | ||
340 | this.timeout(120_000) | ||
341 | |||
342 | // TODO: include peertube_short when https://github.com/ytdl-org/youtube-dl/pull/29475 is merged | ||
343 | for (const targetUrl of [ FIXTURE_URLS.peertube_long ]) { | ||
344 | // for (const targetUrl of [ FIXTURE_URLS.peertube_long, FIXTURE_URLS.peertube_short ]) { | ||
345 | await servers[0].config.disableTranscoding() | ||
346 | |||
347 | const attributes = { | ||
348 | targetUrl, | ||
349 | channelId: channelIdServer1, | ||
350 | privacy: VideoPrivacy.PUBLIC | ||
351 | } | ||
352 | const { video } = await servers[0].imports.importVideo({ attributes }) | ||
353 | const videoUUID = video.uuid | ||
354 | |||
355 | await waitJobs(servers) | ||
356 | |||
357 | for (const server of servers) { | ||
358 | const video = await server.videos.get({ id: videoUUID }) | ||
359 | |||
360 | expect(video.name).to.equal('E2E tests') | ||
361 | } | ||
362 | } | ||
363 | }) | ||
364 | |||
339 | after(async function () { | 365 | after(async function () { |
340 | await cleanupTests(servers) | 366 | await cleanupTests(servers) |
341 | }) | 367 | }) |
diff --git a/shared/extra-utils/miscs/tests.ts b/shared/extra-utils/miscs/tests.ts index dd86041fe..5b5430278 100644 --- a/shared/extra-utils/miscs/tests.ts +++ b/shared/extra-utils/miscs/tests.ts | |||
@@ -2,6 +2,9 @@ import { stat } from 'fs-extra' | |||
2 | import { basename, isAbsolute, join, resolve } from 'path' | 2 | import { basename, isAbsolute, join, resolve } from 'path' |
3 | 3 | ||
4 | const FIXTURE_URLS = { | 4 | const FIXTURE_URLS = { |
5 | peertube_long: 'https://peertube2.cpy.re/videos/watch/122d093a-1ede-43bd-bd34-59d2931ffc5e', | ||
6 | peertube_short: 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd', | ||
7 | |||
5 | youtube: 'https://www.youtube.com/watch?v=msX3jv1XdvM', | 8 | youtube: 'https://www.youtube.com/watch?v=msX3jv1XdvM', |
6 | 9 | ||
7 | /** | 10 | /** |