]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tools/import-videos.ts
Add tests for publishedAt
[github/Chocobozzz/PeerTube.git] / server / tools / import-videos.ts
index 27d0732a6c78c28800a445375b52cd441ffe447c..2f38ea7c77e9f079db666035fd5cafe365f80b71 100644 (file)
@@ -1,3 +1,6 @@
+// FIXME: https://github.com/nodejs/node/pull/16853
+require('tls').DEFAULT_ECDH_CURVE = 'auto'
+
 import * as program from 'commander'
 import { join } from 'path'
 import * as youtubeDL from 'youtube-dl'
@@ -73,7 +76,6 @@ async function run () {
       await processVideo(info, program['language'])
     }
 
-    // https://www.youtube.com/watch?v=2Upx39TBc1s
     console.log('I\'m finished!')
     process.exit(0)
   })
@@ -100,15 +102,21 @@ function processVideo (info: any, languageCode: number) {
     console.log('Downloading video "%s"...', videoInfo.title)
 
     const options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ]
-    youtubeDL.exec(videoInfo.url, options, processOptions, async (err, output) => {
-      if (err) return console.error(err)
-
-      console.log(output.join('\n'))
-
-      await uploadVideoOnPeerTube(normalizeObject(videoInfo), path, languageCode)
-
+    try {
+      youtubeDL.exec(videoInfo.url, options, processOptions, async (err, output) => {
+        if (err) {
+          console.error(err)
+          return res()
+        }
+
+        console.log(output.join('\n'))
+        await uploadVideoOnPeerTube(normalizeObject(videoInfo), path, languageCode)
+        return res()
+      })
+    } catch (err) {
+      console.log(err.message)
       return res()
-    })
+    }
   })
 }
 
@@ -144,7 +152,7 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, languag
     language,
     nsfw: isNSFW(videoInfo),
     commentsEnabled: true,
-    description: videoInfo.description,
+    description: videoInfo.description || undefined,
     support: undefined,
     tags,
     privacy: VideoPrivacy.PUBLIC,