diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-11 17:23:24 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 8d2be0ed7bb87283a1ec98609df6b82d83db706a (patch) | |
tree | 31a36b252df32be83ceb77658a53b57f9d15e8ac /server/tools/peertube-import-videos.ts | |
parent | dba85a1e9e9f603ba52e1ea42deaf3fdd799b1d8 (diff) | |
download | PeerTube-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.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) { |