aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube-import-videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-11 17:23:24 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit8d2be0ed7bb87283a1ec98609df6b82d83db706a (patch)
tree31a36b252df32be83ceb77658a53b57f9d15e8ac /server/tools/peertube-import-videos.ts
parentdba85a1e9e9f603ba52e1ea42deaf3fdd799b1d8 (diff)
downloadPeerTube-8d2be0ed7bb87283a1ec98609df6b82d83db706a.tar.gz
PeerTube-8d2be0ed7bb87283a1ec98609df6b82d83db706a.tar.zst
PeerTube-8d2be0ed7bb87283a1ec98609df6b82d83db706a.zip
WIP plugins: move plugin CLI in peertube script
Install/uninstall/list plugins remotely
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) {