From e8a739e880593c3ffd07a634d5ff62690ed844f6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 24 Apr 2019 16:51:25 +0200 Subject: Fix video import CLI script Password is an optional argument --- server/tools/peertube-import-videos.ts | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'server/tools') diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 8c4c711f7..024f640a4 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -11,7 +11,7 @@ import { truncate } from 'lodash' import * as prompt from 'prompt' import { remove } from 'fs-extra' import { sha256 } from '../helpers/core-utils' -import { safeGetYoutubeDL, buildOriginallyPublishedAt } from '../helpers/youtube-dl' +import { buildOriginallyPublishedAt, safeGetYoutubeDL } from '../helpers/youtube-dl' import { getSettings, netrc } from './cli' let accessToken: string @@ -34,29 +34,19 @@ program getSettings() .then(settings => { - if ( - (!program['url'] || - !program['username'] || - !program['password']) && - (settings.remotes.length === 0) - ) { + if ((!program['url'] || !program['username'] || !program['targetUrl']) && settings.remotes.length === 0) { if (!program['url']) console.error('--url field is required.') if (!program['username']) console.error('--username field is required.') - if (!program['password']) console.error('--password field is required.') if (!program['targetUrl']) console.error('--targetUrl field is required.') + process.exit(-1) } - if ( - (!program['url'] || - !program['username'] || - !program['password']) && - (settings.remotes.length > 0) - ) { - if (!program['url']) { - program['url'] = (settings.default !== -1) ? - settings.remotes[settings.default] : - settings.remotes[0] + if ((!program[ 'url' ] || !program[ 'username' ]) && settings.remotes.length > 0) { + if (!program[ 'url' ]) { + program[ 'url' ] = settings.default !== -1 + ? settings.remotes[ settings.default ] + : settings.remotes[ 0 ] } if (!program['username']) program['username'] = netrc.machines[program['url']].login -- cgit v1.2.3