diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:51:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:51:25 +0200 |
commit | e8a739e880593c3ffd07a634d5ff62690ed844f6 (patch) | |
tree | 28b59be53f44933fb14edba8f9662913a69577c1 | |
parent | cbe94af85a9a7ca4aeaf783a6f8ed5954cba2f44 (diff) | |
download | PeerTube-e8a739e880593c3ffd07a634d5ff62690ed844f6.tar.gz PeerTube-e8a739e880593c3ffd07a634d5ff62690ed844f6.tar.zst PeerTube-e8a739e880593c3ffd07a634d5ff62690ed844f6.zip |
Fix video import CLI script
Password is an optional argument
-rw-r--r-- | server/tools/peertube-import-videos.ts | 26 | ||||
-rw-r--r-- | support/doc/tools.md | 2 |
2 files changed, 9 insertions, 19 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 |
diff --git a/support/doc/tools.md b/support/doc/tools.md index 2ca1d508b..086cd5cff 100644 --- a/support/doc/tools.md +++ b/support/doc/tools.md | |||
@@ -120,7 +120,7 @@ $ node dist/server/tools/peertube-import-videos.js \ | |||
120 | 120 | ||
121 | * `PEERTUBE_URL` : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re | 121 | * `PEERTUBE_URL` : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re |
122 | * `PEERTUBE_USER` : your PeerTube account where videos will be uploaded | 122 | * `PEERTUBE_USER` : your PeerTube account where videos will be uploaded |
123 | * `PEERTUBE_PASSWORD` : password of your PeerTube account (if `PEERTUBE_PASSWORD` is omitted, you will be prompted for it) | 123 | * `PEERTUBE_PASSWORD` : password of your PeerTube account (if `--password PEERTUBE_PASSWORD` is omitted, you will be prompted for it) |
124 | * `TARGET_URL` : the target url you want to import. Examples: | 124 | * `TARGET_URL` : the target url you want to import. Examples: |
125 | * YouTube: | 125 | * YouTube: |
126 | * Channel: https://www.youtube.com/channel/ChannelId | 126 | * Channel: https://www.youtube.com/channel/ChannelId |