diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-06 12:26:58 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-06 12:26:58 +0100 |
commit | 73471b1a52f242e86364ffb077ea6cadb3b07ae2 (patch) | |
tree | 43dbb7748e281f8d80f15326f489cdea10ec857d /server/tools | |
parent | c22419dd265c0c7185bf4197a1cb286eb3d8ebc0 (diff) | |
parent | f5305c04aae14467d6f957b713c5a902275cbb89 (diff) | |
download | PeerTube-73471b1a52f242e86364ffb077ea6cadb3b07ae2.tar.gz PeerTube-73471b1a52f242e86364ffb077ea6cadb3b07ae2.tar.zst PeerTube-73471b1a52f242e86364ffb077ea6cadb3b07ae2.zip |
Merge branch 'release/v1.2.0'
Diffstat (limited to 'server/tools')
-rw-r--r-- | server/tools/peertube-get-access-token.ts | 2 | ||||
-rw-r--r-- | server/tools/peertube-import-videos.ts | 26 | ||||
-rw-r--r-- | server/tools/peertube-upload.ts | 4 |
3 files changed, 25 insertions, 7 deletions
diff --git a/server/tools/peertube-get-access-token.ts b/server/tools/peertube-get-access-token.ts index eb2571a03..a68665f5b 100644 --- a/server/tools/peertube-get-access-token.ts +++ b/server/tools/peertube-get-access-token.ts | |||
@@ -6,7 +6,7 @@ import { | |||
6 | Server, | 6 | Server, |
7 | Client, | 7 | Client, |
8 | User | 8 | User |
9 | } from '../tests/utils/index' | 9 | } from '../../shared/utils' |
10 | 10 | ||
11 | program | 11 | program |
12 | .option('-u, --url <url>', 'Server url') | 12 | .option('-u, --url <url>', 'Server url') |
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 21505b79d..f50aafc35 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts | |||
@@ -6,7 +6,7 @@ import { join } from 'path' | |||
6 | import { VideoPrivacy } from '../../shared/models/videos' | 6 | import { VideoPrivacy } from '../../shared/models/videos' |
7 | import { doRequestAndSaveToFile } from '../helpers/requests' | 7 | import { doRequestAndSaveToFile } from '../helpers/requests' |
8 | import { CONSTRAINTS_FIELDS } from '../initializers' | 8 | import { CONSTRAINTS_FIELDS } from '../initializers' |
9 | import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo } from '../tests/utils' | 9 | import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo } from '../../shared/utils/index' |
10 | import { truncate } from 'lodash' | 10 | import { truncate } from 'lodash' |
11 | import * as prompt from 'prompt' | 11 | import * as prompt from 'prompt' |
12 | import { remove } from 'fs-extra' | 12 | import { remove } from 'fs-extra' |
@@ -58,6 +58,7 @@ getSettings() | |||
58 | settings.remotes[settings.default] : | 58 | settings.remotes[settings.default] : |
59 | settings.remotes[0] | 59 | settings.remotes[0] |
60 | } | 60 | } |
61 | |||
61 | if (!program['username']) program['username'] = netrc.machines[program['url']].login | 62 | if (!program['username']) program['username'] = netrc.machines[program['url']].login |
62 | if (!program['password']) program['password'] = netrc.machines[program['url']].password | 63 | if (!program['password']) program['password'] = netrc.machines[program['url']].password |
63 | } | 64 | } |
@@ -69,12 +70,19 @@ getSettings() | |||
69 | process.exit(-1) | 70 | process.exit(-1) |
70 | } | 71 | } |
71 | 72 | ||
73 | removeEndSlashes(program['url']) | ||
74 | removeEndSlashes(program['targetUrl']) | ||
75 | |||
72 | const user = { | 76 | const user = { |
73 | username: program['username'], | 77 | username: program['username'], |
74 | password: program['password'] | 78 | password: program['password'] |
75 | } | 79 | } |
76 | 80 | ||
77 | run(user, program['url']).catch(err => console.error(err)) | 81 | run(user, program['url']) |
82 | .catch(err => { | ||
83 | console.error(err) | ||
84 | process.exit(-1) | ||
85 | }) | ||
78 | }) | 86 | }) |
79 | 87 | ||
80 | async function promptPassword () { | 88 | async function promptPassword () { |
@@ -108,8 +116,12 @@ async function run (user, url: string) { | |||
108 | secret: res.body.client_secret | 116 | secret: res.body.client_secret |
109 | } | 117 | } |
110 | 118 | ||
111 | const res2 = await login(url, client, user) | 119 | try { |
112 | accessToken = res2.body.access_token | 120 | const res = await login(program[ 'url' ], client, user) |
121 | accessToken = res.body.access_token | ||
122 | } catch (err) { | ||
123 | throw new Error('Cannot authenticate. Please check your username/password.') | ||
124 | } | ||
113 | 125 | ||
114 | const youtubeDL = await safeGetYoutubeDL() | 126 | const youtubeDL = await safeGetYoutubeDL() |
115 | 127 | ||
@@ -321,3 +333,9 @@ function isNSFW (info: any) { | |||
321 | 333 | ||
322 | return false | 334 | return false |
323 | } | 335 | } |
336 | |||
337 | function removeEndSlashes (url: string) { | ||
338 | while (url.endsWith('/')) { | ||
339 | url.slice(0, -1) | ||
340 | } | ||
341 | } | ||
diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index 6248fb47d..cc7bd9b4c 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as program from 'commander' | 1 | import * as program from 'commander' |
2 | import { access, constants } from 'fs-extra' | 2 | import { access, constants } from 'fs-extra' |
3 | import { isAbsolute } from 'path' | 3 | import { isAbsolute } from 'path' |
4 | import { getClient, login } from '../tests/utils' | 4 | import { getClient, login } from '../../shared/utils' |
5 | import { uploadVideo } from '../tests/utils/index' | 5 | import { uploadVideo } from '../../shared/utils/' |
6 | import { VideoPrivacy } from '../../shared/models/videos' | 6 | import { VideoPrivacy } from '../../shared/models/videos' |
7 | import { netrc, getSettings } from './cli' | 7 | import { netrc, getSettings } from './cli' |
8 | 8 | ||