diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-22 14:25:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-22 14:25:32 +0200 |
commit | 5480933b7f088bf099b25fb467faace814f0da58 (patch) | |
tree | 4a813030959bb1b65ab17493f5f694db99883fc0 | |
parent | ab4001aade0891b70e456a215ced0f825c57fde8 (diff) | |
download | PeerTube-5480933b7f088bf099b25fb467faace814f0da58.tar.gz PeerTube-5480933b7f088bf099b25fb467faace814f0da58.tar.zst PeerTube-5480933b7f088bf099b25fb467faace814f0da58.zip |
Add peertube short link import test
-rw-r--r-- | server/helpers/youtube-dl/youtube-dl-wrapper.ts | 4 | ||||
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/server/helpers/youtube-dl/youtube-dl-wrapper.ts b/server/helpers/youtube-dl/youtube-dl-wrapper.ts index 6960fbae4..edbd28fa4 100644 --- a/server/helpers/youtube-dl/youtube-dl-wrapper.ts +++ b/server/helpers/youtube-dl/youtube-dl-wrapper.ts | |||
@@ -73,12 +73,11 @@ class YoutubeDLWrapper { | |||
73 | // Leave empty the extension, youtube-dl will add it | 73 | // Leave empty the extension, youtube-dl will add it |
74 | const pathWithoutExtension = generateVideoImportTmpPath(this.url, '') | 74 | const pathWithoutExtension = generateVideoImportTmpPath(this.url, '') |
75 | 75 | ||
76 | let timer: NodeJS.Timeout | ||
77 | |||
78 | logger.info('Importing youtubeDL video %s to %s', this.url, pathWithoutExtension, lTags()) | 76 | logger.info('Importing youtubeDL video %s to %s', this.url, pathWithoutExtension, lTags()) |
79 | 77 | ||
80 | const youtubeDL = await YoutubeDLCLI.safeGet() | 78 | const youtubeDL = await YoutubeDLCLI.safeGet() |
81 | 79 | ||
80 | let timer: NodeJS.Timeout | ||
82 | const timeoutPromise = new Promise<string>((_, rej) => { | 81 | const timeoutPromise = new Promise<string>((_, rej) => { |
83 | timer = setTimeout(() => rej(new Error('YoutubeDL download timeout.')), timeout) | 82 | timer = setTimeout(() => rej(new Error('YoutubeDL download timeout.')), timeout) |
84 | }) | 83 | }) |
@@ -102,6 +101,7 @@ class YoutubeDLWrapper { | |||
102 | .catch(async err => { | 101 | .catch(async err => { |
103 | const path = await this.guessVideoPathWithExtension(pathWithoutExtension, fileExt) | 102 | const path = await this.guessVideoPathWithExtension(pathWithoutExtension, fileExt) |
104 | 103 | ||
104 | logger.debug('Error in youtube-dl import, deleting file %s.', path, { err, ...lTags() }) | ||
105 | remove(path) | 105 | remove(path) |
106 | .catch(err => logger.error('Cannot remove file in youtubeDL timeout.', { err, ...lTags() })) | 106 | .catch(err => logger.error('Cannot remove file in youtubeDL timeout.', { err, ...lTags() })) |
107 | 107 | ||
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index cfb188060..bb1627a27 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -345,9 +345,14 @@ describe('Test video imports', function () { | |||
345 | it('Should import a peertube video', async function () { | 345 | it('Should import a peertube video', async function () { |
346 | this.timeout(120_000) | 346 | this.timeout(120_000) |
347 | 347 | ||
348 | const toTest = [ FIXTURE_URLS.peertube_long ] | ||
349 | |||
348 | // TODO: include peertube_short when https://github.com/ytdl-org/youtube-dl/pull/29475 is merged | 350 | // TODO: include peertube_short when https://github.com/ytdl-org/youtube-dl/pull/29475 is merged |
349 | for (const targetUrl of [ FIXTURE_URLS.peertube_long ]) { | 351 | if (mode === 'yt-dlp') { |
350 | // for (const targetUrl of [ FIXTURE_URLS.peertube_long, FIXTURE_URLS.peertube_short ]) { | 352 | toTest.push(FIXTURE_URLS.peertube_short) |
353 | } | ||
354 | |||
355 | for (const targetUrl of toTest) { | ||
351 | await servers[0].config.disableTranscoding() | 356 | await servers[0].config.disableTranscoding() |
352 | 357 | ||
353 | const attributes = { | 358 | const attributes = { |