aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/tools/peertube-import-videos.ts26
-rw-r--r--support/doc/tools.md2
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'
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
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