aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/import-videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools/import-videos.ts')
-rw-r--r--server/tools/import-videos.ts38
1 files changed, 32 insertions, 6 deletions
diff --git a/server/tools/import-videos.ts b/server/tools/import-videos.ts
index f773208ab..91b897976 100644
--- a/server/tools/import-videos.ts
+++ b/server/tools/import-videos.ts
@@ -10,6 +10,7 @@ import { doRequestAndSaveToFile } from '../helpers/requests'
10import { CONSTRAINTS_FIELDS } from '../initializers' 10import { CONSTRAINTS_FIELDS } from '../initializers'
11import { getClient, getVideoCategories, login, searchVideo, uploadVideo } from '../tests/utils' 11import { getClient, getVideoCategories, login, searchVideo, uploadVideo } from '../tests/utils'
12import { truncate } from 'lodash' 12import { truncate } from 'lodash'
13import * as prompt from 'prompt'
13 14
14program 15program
15 .option('-u, --url <url>', 'Server url') 16 .option('-u, --url <url>', 'Server url')
@@ -23,29 +24,54 @@ program
23if ( 24if (
24 !program['url'] || 25 !program['url'] ||
25 !program['username'] || 26 !program['username'] ||
26 !program['password'] ||
27 !program['targetUrl'] 27 !program['targetUrl']
28) { 28) {
29 console.error('All arguments are required.') 29 console.error('All arguments are required.')
30 process.exit(-1) 30 process.exit(-1)
31} 31}
32 32
33run().catch(err => console.error(err))
34
35let accessToken: string
36let client: { id: string, secret: string }
37
38const user = { 33const user = {
39 username: program['username'], 34 username: program['username'],
40 password: program['password'] 35 password: program['password']
41} 36}
42 37
38run().catch(err => console.error(err))
39
40let accessToken: string
41let client: { id: string, secret: string }
42
43const processOptions = { 43const processOptions = {
44 cwd: __dirname, 44 cwd: __dirname,
45 maxBuffer: Infinity 45 maxBuffer: Infinity
46} 46}
47 47
48async function promptPassword () {
49 return new Promise ( resolve => {
50 prompt.start()
51 const schema = {
52 properties: {
53 password: {
54 hidden:true,
55 required:true
56 }
57 }
58 }
59 prompt.get(schema, function(err, result) {
60 if (err) {
61 console.log(err.message)
62 }
63 resolve(result.password)
64 })
65 })
66}
67
48async function run () { 68async function run () {
69 if (
70 !user.password
71 ) {
72 user.password = await promptPassword();
73 }
74
49 const res = await getClient(program['url']) 75 const res = await getClient(program['url'])
50 client = { 76 client = {
51 id: res.body.client_id, 77 id: res.body.client_id,