]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add peertube short link import test
authorChocobozzz <me@florianbigard.com>
Fri, 22 Oct 2021 12:25:19 +0000 (14:25 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 22 Oct 2021 12:25:32 +0000 (14:25 +0200)
server/helpers/youtube-dl/youtube-dl-wrapper.ts
server/tests/api/videos/video-imports.ts

index 6960fbae4ec4dbf01b2a7908b54a29ce759f499c..edbd28fa466ba1430e77901c87cc95b42fd17590 100644 (file)
@@ -73,12 +73,11 @@ class YoutubeDLWrapper {
     // Leave empty the extension, youtube-dl will add it
     const pathWithoutExtension = generateVideoImportTmpPath(this.url, '')
 
-    let timer: NodeJS.Timeout
-
     logger.info('Importing youtubeDL video %s to %s', this.url, pathWithoutExtension, lTags())
 
     const youtubeDL = await YoutubeDLCLI.safeGet()
 
+    let timer: NodeJS.Timeout
     const timeoutPromise = new Promise<string>((_, rej) => {
       timer = setTimeout(() => rej(new Error('YoutubeDL download timeout.')), timeout)
     })
@@ -102,6 +101,7 @@ class YoutubeDLWrapper {
       .catch(async err => {
         const path = await this.guessVideoPathWithExtension(pathWithoutExtension, fileExt)
 
+        logger.debug('Error in youtube-dl import, deleting file %s.', path, { err, ...lTags() })
         remove(path)
           .catch(err => logger.error('Cannot remove file in youtubeDL timeout.', { err, ...lTags() }))
 
index cfb18806093f3783da52a05e5ca9eb10d94407ba..bb1627a27786ae5d86561c0b3e7a362e52c2c089 100644 (file)
@@ -345,9 +345,14 @@ describe('Test video imports', function () {
       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
-        for (const targetUrl of [ FIXTURE_URLS.peertube_long ]) {
-        // for (const targetUrl of [ FIXTURE_URLS.peertube_long, FIXTURE_URLS.peertube_short ]) {
+        if (mode === 'yt-dlp') {
+          toTest.push(FIXTURE_URLS.peertube_short)
+        }
+
+        for (const targetUrl of toTest) {
           await servers[0].config.disableTranscoding()
 
           const attributes = {