aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube-import-videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools/peertube-import-videos.ts')
-rw-r--r--server/tools/peertube-import-videos.ts34
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'
11import { remove } from 'fs-extra' 11import { remove } from 'fs-extra'
12import { sha256 } from '../helpers/core-utils' 12import { sha256 } from '../helpers/core-utils'
13import { buildOriginallyPublishedAt, safeGetYoutubeDL } from '../helpers/youtube-dl' 13import { buildOriginallyPublishedAt, safeGetYoutubeDL } from '../helpers/youtube-dl'
14import { buildCommonVideoOptions, buildVideoAttributesFromCommander, getNetrc, getRemoteObjectOrDie, getSettings } from './cli' 14import { buildCommonVideoOptions, buildVideoAttributesFromCommander, getServerCredentials } from './cli'
15 15
16type UserInfo = { 16type 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
39Promise.all([ getSettings(), getNetrc() ]) 39getServerCredentials(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
61async function run (url: string, user: UserInfo) { 59async function run (url: string, user: UserInfo) {
62 if (!user.password) { 60 if (!user.password) {