]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tools/peertube-upload.ts
Define channelId property beforehand
[github/Chocobozzz/PeerTube.git] / server / tools / peertube-upload.ts
index 1f871e660ff555e7a59b2be1f21365822bc0c425..6248fb47d648f6cc1519f9892080991582e8b363 100644 (file)
@@ -15,6 +15,7 @@ program
   .option('-P, --privacy <privacy_number>', 'Privacy')
   .option('-N, --nsfw', 'Video is Not Safe For Work')
   .option('-c, --category <category_number>', 'Category number')
+  .option('-C, --channel-id <channel_id>', 'Channel ID')
   .option('-m, --comments-enabled', 'Enable comments')
   .option('-l, --licence <licence_number>', 'Licence number')
   .option('-L, --language <language_code>', 'Language ISO 639 code (fr or en...)')
@@ -75,7 +76,10 @@ getSettings()
       process.exit(-1)
     }
 
-    run().catch(err => console.error(err))
+    run().catch(err => {
+      console.error(err)
+      process.exit(-1)
+    })
   })
 
 async function run () {
@@ -90,8 +94,13 @@ async function run () {
     password: program[ 'password' ]
   }
 
-  const res2 = await login(program[ 'url' ], client, user)
-  const accessToken = res2.body.access_token
+  let accessToken: string
+  try {
+    const res2 = await login(program[ 'url' ], client, user)
+    accessToken = res2.body.access_token
+  } catch (err) {
+    throw new Error('Cannot authenticate. Please check your username/password.')
+  }
 
   await access(program[ 'file' ], constants.F_OK)
 
@@ -100,6 +109,7 @@ async function run () {
   const videoAttributes = {
     name: program['videoName'],
     category: program['category'],
+    channelId: program['channelId'],
     licence: program['licence'],
     language: program['language'],
     nsfw: program['nsfw'],
@@ -114,7 +124,7 @@ async function run () {
     support: undefined
   }
 
-  await uploadVideo(program['url'], accessToken, videoAttributes)
+  await uploadVideo(program[ 'url' ], accessToken, videoAttributes)
 
   console.log(`Video ${program['videoName']} uploaded.`)
   process.exit(0)