aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohn Livingston <git@john-livingston.fr>2018-05-10 23:59:28 +0200
committerChocobozzz <me@florianbigard.com>2018-05-11 15:23:50 +0200
commit066fc8ba71fa3573d1b1fb4c692b8f51c17111fc (patch)
treea3f2e85b76488d129ddd94e5e69579116dce4adc
parent8be1afa12b700b93ed92365cab05c0ef81d643aa (diff)
downloadPeerTube-066fc8ba71fa3573d1b1fb4c692b8f51c17111fc.tar.gz
PeerTube-066fc8ba71fa3573d1b1fb4c692b8f51c17111fc.tar.zst
PeerTube-066fc8ba71fa3573d1b1fb4c692b8f51c17111fc.zip
import-videos: prompt for password
-rw-r--r--package.json1
-rw-r--r--server/tools/import-videos.ts38
-rw-r--r--support/doc/tools.md2
-rw-r--r--yarn.lock92
4 files changed, 124 insertions, 9 deletions
diff --git a/package.json b/package.json
index 821c00c72..3b399f3a8 100644
--- a/package.json
+++ b/package.json
@@ -138,6 +138,7 @@
138 "maildev": "^1.0.0-rc3", 138 "maildev": "^1.0.0-rc3",
139 "mocha": "^5.0.0", 139 "mocha": "^5.0.0",
140 "nodemon": "^1.11.0", 140 "nodemon": "^1.11.0",
141 "prompt": "^1.0.0",
141 "source-map-support": "^0.5.0", 142 "source-map-support": "^0.5.0",
142 "spectacle-docs": "^1.0.2", 143 "spectacle-docs": "^1.0.2",
143 "supertest": "^3.0.0", 144 "supertest": "^3.0.0",
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,
diff --git a/support/doc/tools.md b/support/doc/tools.md
index d83203369..fb6c2cdc4 100644
--- a/support/doc/tools.md
+++ b/support/doc/tools.md
@@ -53,7 +53,7 @@ $ node dist/server/tools/import-videos.js -u "PEERTUBE_URL" -U "PEERTUBE_USER" -
53 53
54 * PEERTUBE_URL : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re/ 54 * PEERTUBE_URL : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re/
55 * PEERTUBE_USER : your PeerTube account where videos will be uploaded 55 * PEERTUBE_USER : your PeerTube account where videos will be uploaded
56 * PEERTUBE_PASSWORD : password of your PeerTube account 56 * PEERTUBE_PASSWORD : password of your PeerTube account (if ommited, you will be prompted for)
57 * TARGET_URL : the target url you want to import. Examples: 57 * TARGET_URL : the target url you want to import. Examples:
58 * YouTube: 58 * YouTube:
59 * Channel: https://www.youtube.com/channel/ChannelId 59 * Channel: https://www.youtube.com/channel/ChannelId
diff --git a/yarn.lock b/yarn.lock
index a51cfe121..4822a4dc1 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -570,6 +570,10 @@ async@~0.2.6, async@~0.2.9:
570 version "0.2.10" 570 version "0.2.10"
571 resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" 571 resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1"
572 572
573async@~1.0.0:
574 version "1.0.0"
575 resolved "https://registry.yarnpkg.com/async/-/async-1.0.0.tgz#f8fc04ca3a13784ade9e1641af98578cfbd647a9"
576
573asynckit@^0.4.0: 577asynckit@^0.4.0:
574 version "0.4.0" 578 version "0.4.0"
575 resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" 579 resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
@@ -1322,6 +1326,14 @@ colornames@0.0.2:
1322 version "0.0.2" 1326 version "0.0.2"
1323 resolved "https://registry.yarnpkg.com/colornames/-/colornames-0.0.2.tgz#d811fd6c84f59029499a8ac4436202935b92be31" 1327 resolved "https://registry.yarnpkg.com/colornames/-/colornames-0.0.2.tgz#d811fd6c84f59029499a8ac4436202935b92be31"
1324 1328
1329colors@1.0.x:
1330 version "1.0.3"
1331 resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
1332
1333colors@^1.1.2:
1334 version "1.2.4"
1335 resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.4.tgz#e0cb41d3e4b20806b3bfc27f4559f01b94bc2f7c"
1336
1325colors@^1.2.0: 1337colors@^1.2.0:
1326 version "1.2.1" 1338 version "1.2.1"
1327 resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.1.tgz#f4a3d302976aaf042356ba1ade3b1a2c62d9d794" 1339 resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.1.tgz#f4a3d302976aaf042356ba1ade3b1a2c62d9d794"
@@ -1600,6 +1612,10 @@ currently-unhandled@^0.4.1:
1600 dependencies: 1612 dependencies:
1601 array-find-index "^1.0.1" 1613 array-find-index "^1.0.1"
1602 1614
1615cycle@1.0.x:
1616 version "1.0.3"
1617 resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2"
1618
1603dashdash@^1.12.0: 1619dashdash@^1.12.0:
1604 version "1.14.1" 1620 version "1.14.1"
1605 resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" 1621 resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
@@ -1668,6 +1684,10 @@ deep-eql@^3.0.0:
1668 dependencies: 1684 dependencies:
1669 type-detect "^4.0.0" 1685 type-detect "^4.0.0"
1670 1686
1687deep-equal@~0.2.1:
1688 version "0.2.2"
1689 resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-0.2.2.tgz#84b745896f34c684e98f2ce0e42abaf43bba017d"
1690
1671deep-extend@~0.4.0: 1691deep-extend@~0.4.0:
1672 version "0.4.2" 1692 version "0.4.2"
1673 resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" 1693 resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
@@ -2155,6 +2175,10 @@ extsprintf@^1.2.0:
2155 version "1.4.0" 2175 version "1.4.0"
2156 resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" 2176 resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f"
2157 2177
2178eyes@0.1.x:
2179 version "0.1.8"
2180 resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0"
2181
2158fast-deep-equal@^1.0.0: 2182fast-deep-equal@^1.0.0:
2159 version "1.1.0" 2183 version "1.1.0"
2160 resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614" 2184 resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614"
@@ -3003,6 +3027,10 @@ http-signature@~1.2.0:
3003 jsprim "^1.2.2" 3027 jsprim "^1.2.2"
3004 sshpk "^1.7.0" 3028 sshpk "^1.7.0"
3005 3029
3030i@0.3.x:
3031 version "0.3.6"
3032 resolved "https://registry.yarnpkg.com/i/-/i-0.3.6.tgz#d96c92732076f072711b6b10fd7d4f65ad8ee23d"
3033
3006iconv-lite@0.4.19: 3034iconv-lite@0.4.19:
3007 version "0.4.19" 3035 version "0.4.19"
3008 resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" 3036 resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
@@ -4070,7 +4098,7 @@ mixin-deep@^1.2.0:
4070 for-in "^1.0.2" 4098 for-in "^1.0.2"
4071 is-extendable "^1.0.1" 4099 is-extendable "^1.0.1"
4072 4100
4073mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0: 4101mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@0.x.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0:
4074 version "0.5.1" 4102 version "0.5.1"
4075 resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" 4103 resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
4076 dependencies: 4104 dependencies:
@@ -4166,6 +4194,10 @@ multistream@^2.0.2, multistream@^2.0.5:
4166 inherits "^2.0.1" 4194 inherits "^2.0.1"
4167 readable-stream "^2.0.5" 4195 readable-stream "^2.0.5"
4168 4196
4197mute-stream@~0.0.4:
4198 version "0.0.7"
4199 resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
4200
4169nan@2.6.2: 4201nan@2.6.2:
4170 version "2.6.2" 4202 version "2.6.2"
4171 resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" 4203 resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45"
@@ -4207,6 +4239,10 @@ natural@^0.2.0:
4207 sylvester ">= 0.0.12" 4239 sylvester ">= 0.0.12"
4208 underscore ">=1.3.1" 4240 underscore ">=1.3.1"
4209 4241
4242ncp@1.0.x:
4243 version "1.0.1"
4244 resolved "https://registry.yarnpkg.com/ncp/-/ncp-1.0.1.tgz#d15367e5cb87432ba117d2bf80fdf45aecfb4246"
4245
4210negotiator@0.5.3: 4246negotiator@0.5.3:
4211 version "0.5.3" 4247 version "0.5.3"
4212 resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.5.3.tgz#269d5c476810ec92edbe7b6c2f28316384f9a7e8" 4248 resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.5.3.tgz#269d5c476810ec92edbe7b6c2f28316384f9a7e8"
@@ -4779,6 +4815,14 @@ pinkie@^2.0.0:
4779 version "2.0.4" 4815 version "2.0.4"
4780 resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" 4816 resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
4781 4817
4818pkginfo@0.3.x:
4819 version "0.3.1"
4820 resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21"
4821
4822pkginfo@0.x.x:
4823 version "0.4.1"
4824 resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff"
4825
4782portscanner@^1.0.0: 4826portscanner@^1.0.0:
4783 version "1.2.0" 4827 version "1.2.0"
4784 resolved "https://registry.yarnpkg.com/portscanner/-/portscanner-1.2.0.tgz#b14bbda257d14c310fa9cc09682af02d40961802" 4828 resolved "https://registry.yarnpkg.com/portscanner/-/portscanner-1.2.0.tgz#b14bbda257d14c310fa9cc09682af02d40961802"
@@ -4869,6 +4913,17 @@ promisify-any@2.0.1:
4869 co-bluebird "^1.1.0" 4913 co-bluebird "^1.1.0"
4870 is-generator "^1.0.2" 4914 is-generator "^1.0.2"
4871 4915
4916prompt@^1.0.0:
4917 version "1.0.0"
4918 resolved "https://registry.yarnpkg.com/prompt/-/prompt-1.0.0.tgz#8e57123c396ab988897fb327fd3aedc3e735e4fe"
4919 dependencies:
4920 colors "^1.1.2"
4921 pkginfo "0.x.x"
4922 read "1.0.x"
4923 revalidator "0.1.x"
4924 utile "0.3.x"
4925 winston "2.1.x"
4926
4872proto-list@~1.2.1: 4927proto-list@~1.2.1:
4873 version "1.2.4" 4928 version "1.2.4"
4874 resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" 4929 resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"
@@ -5125,6 +5180,12 @@ read-pkg@^1.0.0:
5125 normalize-package-data "^2.3.2" 5180 normalize-package-data "^2.3.2"
5126 path-type "^1.0.0" 5181 path-type "^1.0.0"
5127 5182
5183read@1.0.x:
5184 version "1.0.7"
5185 resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4"
5186 dependencies:
5187 mute-stream "~0.0.4"
5188
5128readable-stream@1.1: 5189readable-stream@1.1:
5129 version "1.1.13" 5190 version "1.1.13"
5130 resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.13.tgz#f6eef764f514c89e2b9e23146a75ba106756d23e" 5191 resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.13.tgz#f6eef764f514c89e2b9e23146a75ba106756d23e"
@@ -5390,13 +5451,17 @@ retry-as-promised@^2.3.2:
5390 bluebird "^3.4.6" 5451 bluebird "^3.4.6"
5391 debug "^2.6.9" 5452 debug "^2.6.9"
5392 5453
5454revalidator@0.1.x:
5455 version "0.1.8"
5456 resolved "https://registry.yarnpkg.com/revalidator/-/revalidator-0.1.8.tgz#fece61bfa0c1b52a206bd6b18198184bdd523a3b"
5457
5393right-align@^0.1.1: 5458right-align@^0.1.1:
5394 version "0.1.3" 5459 version "0.1.3"
5395 resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" 5460 resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef"
5396 dependencies: 5461 dependencies:
5397 align-text "^0.1.1" 5462 align-text "^0.1.1"
5398 5463
5399rimraf@2, rimraf@^2.2.1, rimraf@^2.4.2, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1: 5464rimraf@2, rimraf@2.x.x, rimraf@^2.2.1, rimraf@^2.4.2, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1:
5400 version "2.6.2" 5465 version "2.6.2"
5401 resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" 5466 resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
5402 dependencies: 5467 dependencies:
@@ -6674,6 +6739,17 @@ util-deprecate@~1.0.1:
6674 version "1.0.2" 6739 version "1.0.2"
6675 resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" 6740 resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
6676 6741
6742utile@0.3.x:
6743 version "0.3.0"
6744 resolved "https://registry.yarnpkg.com/utile/-/utile-0.3.0.tgz#1352c340eb820e4d8ddba039a4fbfaa32ed4ef3a"
6745 dependencies:
6746 async "~0.9.0"
6747 deep-equal "~0.2.1"
6748 i "0.3.x"
6749 mkdirp "0.x.x"
6750 ncp "1.0.x"
6751 rimraf "2.x.x"
6752
6677utils-merge@1.0.0: 6753utils-merge@1.0.0:
6678 version "1.0.0" 6754 version "1.0.0"
6679 resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8" 6755 resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8"
@@ -6844,6 +6920,18 @@ winston-transport@^3.0.1:
6844 version "3.1.0" 6920 version "3.1.0"
6845 resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-3.1.0.tgz#52b097176c5c26acf9c603630c57ffd575c42572" 6921 resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-3.1.0.tgz#52b097176c5c26acf9c603630c57ffd575c42572"
6846 6922
6923winston@2.1.x:
6924 version "2.1.1"
6925 resolved "https://registry.yarnpkg.com/winston/-/winston-2.1.1.tgz#3c9349d196207fd1bdff9d4bc43ef72510e3a12e"
6926 dependencies:
6927 async "~1.0.0"
6928 colors "1.0.x"
6929 cycle "1.0.x"
6930 eyes "0.1.x"
6931 isstream "0.1.x"
6932 pkginfo "0.3.x"
6933 stack-trace "0.0.x"
6934
6847winston@3.0.0-rc1: 6935winston@3.0.0-rc1:
6848 version "3.0.0-rc1" 6936 version "3.0.0-rc1"
6849 resolved "https://registry.yarnpkg.com/winston/-/winston-3.0.0-rc1.tgz#982bc0ad4ef5c53000ca68036d78a3deaa28cac5" 6937 resolved "https://registry.yarnpkg.com/winston/-/winston-3.0.0-rc1.tgz#982bc0ad4ef5c53000ca68036d78a3deaa28cac5"