]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tools/cli.ts
Fix socket notification with multiple user tabs
[github/Chocobozzz/PeerTube.git] / server / tools / cli.ts
index 2eec51aa490a96506864dd2955f3f19b0559b295..8599a270fe03fc54b8716d252f0bcb15089aa539 100644 (file)
@@ -1,7 +1,8 @@
 import { Netrc } from 'netrc-parser'
 import { getAppNumber, isTestInstance } from '../helpers/core-utils'
 import { join } from 'path'
-import { getVideoChannel, root } from '../../shared/extra-utils'
+import { root } from '../../shared/extra-utils/miscs/miscs'
+import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels'
 import { Command } from 'commander'
 import { VideoChannel, VideoPrivacy } from '../../shared/models/videos'
 
@@ -64,7 +65,11 @@ function deleteSettings () {
   })
 }
 
-function getRemoteObjectOrDie (program: any, settings: Settings, netrc: Netrc) {
+function getRemoteObjectOrDie (
+  program: any,
+  settings: Settings,
+  netrc: Netrc
+): { url: string, username: string, password: string } {
   if (!program['url'] || !program['username'] || !program['password']) {
     // No remote and we don't have program parameters: quit
     if (settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) {
@@ -116,7 +121,7 @@ function buildCommonVideoOptions (command: Command) {
     .option('-w, --wait-transcoding', 'Wait transcoding before publishing the video')
 }
 
-async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any) {
+async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any = {}) {
   const defaultBooleanAttributes = {
     nsfw: false,
     commentsEnabled: true,
@@ -142,7 +147,9 @@ async function buildVideoAttributesFromCommander (url: string, command: Command,
     licence: command[ 'licence' ] || defaultAttributes.licence || undefined,
     language: command[ 'language' ] || defaultAttributes.language || undefined,
     privacy: command[ 'privacy' ] || defaultAttributes.privacy || VideoPrivacy.PUBLIC,
-    support: command[ 'support' ] || defaultAttributes.support || undefined
+    support: command[ 'support' ] || defaultAttributes.support || undefined,
+    description: command[ 'videoDescription' ] || defaultAttributes.description || undefined,
+    tags: command[ 'tags' ] || defaultAttributes.tags || undefined
   }
 
   Object.assign(videoAttributes, booleanAttributes)
@@ -161,6 +168,13 @@ async function buildVideoAttributesFromCommander (url: string, command: Command,
   return videoAttributes
 }
 
+function getServerCredentials (program: any) {
+  return Promise.all([ getSettings(), getNetrc() ])
+         .then(([ settings, netrc ]) => {
+           return getRemoteObjectOrDie(program, settings, netrc)
+         })
+}
+
 // ---------------------------------------------------------------------------
 
 export {
@@ -172,6 +186,8 @@ export {
   writeSettings,
   deleteSettings,
 
+  getServerCredentials,
+
   buildCommonVideoOptions,
   buildVideoAttributesFromCommander
 }