diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/tools/peertube-import-videos.ts | 26 |
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' | |||
11 | import * as prompt from 'prompt' | 11 | import * as prompt from 'prompt' |
12 | import { remove } from 'fs-extra' | 12 | import { remove } from 'fs-extra' |
13 | import { sha256 } from '../helpers/core-utils' | 13 | import { sha256 } from '../helpers/core-utils' |
14 | import { safeGetYoutubeDL, buildOriginallyPublishedAt } from '../helpers/youtube-dl' | 14 | import { buildOriginallyPublishedAt, safeGetYoutubeDL } from '../helpers/youtube-dl' |
15 | import { getSettings, netrc } from './cli' | 15 | import { getSettings, netrc } from './cli' |
16 | 16 | ||
17 | let accessToken: string | 17 | let accessToken: string |
@@ -34,29 +34,19 @@ program | |||
34 | 34 | ||
35 | getSettings() | 35 | getSettings() |
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 |