diff options
Diffstat (limited to 'server/tools/peertube-import-videos.ts')
-rw-r--r-- | server/tools/peertube-import-videos.ts | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index d7bb00e02..1f0350442 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts | |||
@@ -11,7 +11,7 @@ import * as prompt from 'prompt' | |||
11 | import { remove } from 'fs-extra' | 11 | import { remove } from 'fs-extra' |
12 | import { sha256 } from '../helpers/core-utils' | 12 | import { sha256 } from '../helpers/core-utils' |
13 | import { buildOriginallyPublishedAt, safeGetYoutubeDL } from '../helpers/youtube-dl' | 13 | import { buildOriginallyPublishedAt, safeGetYoutubeDL } from '../helpers/youtube-dl' |
14 | import { buildCommonVideoOptions, buildVideoAttributesFromCommander, getNetrc, getRemoteObjectOrDie, getSettings } from './cli' | 14 | import { buildCommonVideoOptions, buildVideoAttributesFromCommander, getServerCredentials } from './cli' |
15 | 15 | ||
16 | type UserInfo = { | 16 | type UserInfo = { |
17 | username: string | 17 | username: string |
@@ -36,27 +36,25 @@ command | |||
36 | .option('-v, --verbose', 'Verbose mode') | 36 | .option('-v, --verbose', 'Verbose mode') |
37 | .parse(process.argv) | 37 | .parse(process.argv) |
38 | 38 | ||
39 | Promise.all([ getSettings(), getNetrc() ]) | 39 | getServerCredentials(command) |
40 | .then(([ settings, netrc ]) => { | 40 | .then(({ url, username, password }) => { |
41 | const { url, username, password } = getRemoteObjectOrDie(program, settings, netrc) | 41 | if (!program[ 'targetUrl' ]) { |
42 | console.error('--targetUrl field is required.') | ||
42 | 43 | ||
43 | if (!program[ 'targetUrl' ]) { | 44 | process.exit(-1) |
44 | console.error('--targetUrl field is required.') | 45 | } |
45 | |||
46 | process.exit(-1) | ||
47 | } | ||
48 | 46 | ||
49 | removeEndSlashes(url) | 47 | removeEndSlashes(url) |
50 | removeEndSlashes(program[ 'targetUrl' ]) | 48 | removeEndSlashes(program[ 'targetUrl' ]) |
51 | 49 | ||
52 | const user = { username, password } | 50 | const user = { username, password } |
53 | 51 | ||
54 | run(url, user) | 52 | run(url, user) |
55 | .catch(err => { | 53 | .catch(err => { |
56 | console.error(err) | 54 | console.error(err) |
57 | process.exit(-1) | 55 | process.exit(-1) |
58 | }) | 56 | }) |
59 | }) | 57 | }) |
60 | 58 | ||
61 | async function run (url: string, user: UserInfo) { | 59 | async function run (url: string, user: UserInfo) { |
62 | if (!user.password) { | 60 | if (!user.password) { |