aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-24 16:51:25 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:51:25 +0200
commite8a739e880593c3ffd07a634d5ff62690ed844f6 (patch)
tree28b59be53f44933fb14edba8f9662913a69577c1 /server
parentcbe94af85a9a7ca4aeaf783a6f8ed5954cba2f44 (diff)
downloadPeerTube-e8a739e880593c3ffd07a634d5ff62690ed844f6.tar.gz
PeerTube-e8a739e880593c3ffd07a634d5ff62690ed844f6.tar.zst
PeerTube-e8a739e880593c3ffd07a634d5ff62690ed844f6.zip
Fix video import CLI script
Password is an optional argument
Diffstat (limited to 'server')
-rw-r--r--server/tools/peertube-import-videos.ts26
1 files changed, 8 insertions, 18 deletions
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'
11import * as prompt from 'prompt' 11import * as prompt from 'prompt'
12import { remove } from 'fs-extra' 12import { remove } from 'fs-extra'
13import { sha256 } from '../helpers/core-utils' 13import { sha256 } from '../helpers/core-utils'
14import { safeGetYoutubeDL, buildOriginallyPublishedAt } from '../helpers/youtube-dl' 14import { buildOriginallyPublishedAt, safeGetYoutubeDL } from '../helpers/youtube-dl'
15import { getSettings, netrc } from './cli' 15import { getSettings, netrc } from './cli'
16 16
17let accessToken: string 17let accessToken: string
@@ -34,29 +34,19 @@ program
34 34
35getSettings() 35getSettings()
36.then(settings => { 36.then(settings => {
37 if ( 37 if ((!program['url'] || !program['username'] || !program['targetUrl']) && settings.remotes.length === 0) {
38 (!program['url'] ||
39 !program['username'] ||
40 !program['password']) &&
41 (settings.remotes.length === 0)
42 ) {
43 if (!program['url']) console.error('--url field is required.') 38 if (!program['url']) console.error('--url field is required.')
44 if (!program['username']) console.error('--username field is required.') 39 if (!program['username']) console.error('--username field is required.')
45 if (!program['password']) console.error('--password field is required.')
46 if (!program['targetUrl']) console.error('--targetUrl field is required.') 40 if (!program['targetUrl']) console.error('--targetUrl field is required.')
41
47 process.exit(-1) 42 process.exit(-1)
48 } 43 }
49 44
50 if ( 45 if ((!program[ 'url' ] || !program[ 'username' ]) && settings.remotes.length > 0) {
51 (!program['url'] || 46 if (!program[ 'url' ]) {
52 !program['username'] || 47 program[ 'url' ] = settings.default !== -1
53 !program['password']) && 48 ? settings.remotes[ settings.default ]
54 (settings.remotes.length > 0) 49 : settings.remotes[ 0 ]
55 ) {
56 if (!program['url']) {
57 program['url'] = (settings.default !== -1) ?
58 settings.remotes[settings.default] :
59 settings.remotes[0]
60 } 50 }
61 51
62 if (!program['username']) program['username'] = netrc.machines[program['url']].login 52 if (!program['username']) program['username'] = netrc.machines[program['url']].login