X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftools%2Fcli.ts;h=8599a270fe03fc54b8716d252f0bcb15089aa539;hb=015d9dec91ecb7a17e4e79407d187aac8a19206d;hp=2eec51aa490a96506864dd2955f3f19b0559b295;hpb=6b226c32782ea7779ced56c1e1090d8b51c5c504;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tools/cli.ts b/server/tools/cli.ts index 2eec51aa4..8599a270f 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts @@ -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 }