diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-13 11:44:16 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | d0a0fa429d4651710ed951a3c11af0219e408964 (patch) | |
tree | c0638f2604e3442d1f15715b9b0f01ecab17ab20 /server/tools/peertube-import-videos.ts | |
parent | 41d1d075011174e73dccb74006181a92a618d7b4 (diff) | |
download | PeerTube-d0a0fa429d4651710ed951a3c11af0219e408964.tar.gz PeerTube-d0a0fa429d4651710ed951a3c11af0219e408964.tar.zst PeerTube-d0a0fa429d4651710ed951a3c11af0219e408964.zip |
Adapt CLI to new commands
Diffstat (limited to 'server/tools/peertube-import-videos.ts')
-rw-r--r-- | server/tools/peertube-import-videos.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index a546a8dbe..0a4d6fa6e 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts | |||
@@ -14,10 +14,10 @@ import { sha256 } from '../helpers/core-utils' | |||
14 | import { doRequestAndSaveToFile } from '../helpers/requests' | 14 | import { doRequestAndSaveToFile } from '../helpers/requests' |
15 | import { CONSTRAINTS_FIELDS } from '../initializers/constants' | 15 | import { CONSTRAINTS_FIELDS } from '../initializers/constants' |
16 | import { | 16 | import { |
17 | assignToken, | ||
17 | buildCommonVideoOptions, | 18 | buildCommonVideoOptions, |
18 | buildServer, | 19 | buildServer, |
19 | buildVideoAttributesFromCommander, | 20 | buildVideoAttributesFromCommander, |
20 | getAccessTokenOrDie, | ||
21 | getLogger, | 21 | getLogger, |
22 | getServerCredentials | 22 | getServerCredentials |
23 | } from './cli' | 23 | } from './cli' |
@@ -232,8 +232,8 @@ async function uploadVideoOnPeerTube (parameters: { | |||
232 | tags | 232 | tags |
233 | } | 233 | } |
234 | 234 | ||
235 | let accessToken = await getAccessTokenOrDie(url, username, password) | 235 | const server = buildServer(url) |
236 | const server = buildServer(url, accessToken) | 236 | await assignToken(server, username, password) |
237 | 237 | ||
238 | const videoAttributes = await buildVideoAttributesFromCommander(server, program, defaultAttributes) | 238 | const videoAttributes = await buildVideoAttributesFromCommander(server, program, defaultAttributes) |
239 | 239 | ||
@@ -247,14 +247,14 @@ async function uploadVideoOnPeerTube (parameters: { | |||
247 | log.info('\nUploading on PeerTube video "%s".', videoAttributes.name) | 247 | log.info('\nUploading on PeerTube video "%s".', videoAttributes.name) |
248 | 248 | ||
249 | try { | 249 | try { |
250 | await uploadVideo(url, accessToken, videoAttributes) | 250 | await uploadVideo(url, server.accessToken, videoAttributes) |
251 | } catch (err) { | 251 | } catch (err) { |
252 | if (err.message.indexOf('401') !== -1) { | 252 | if (err.message.indexOf('401') !== -1) { |
253 | log.info('Got 401 Unauthorized, token may have expired, renewing token and retry.') | 253 | log.info('Got 401 Unauthorized, token may have expired, renewing token and retry.') |
254 | 254 | ||
255 | accessToken = await getAccessTokenOrDie(url, username, password) | 255 | server.accessToken = await server.loginCommand.getAccessToken(username, password) |
256 | 256 | ||
257 | await uploadVideo(url, accessToken, videoAttributes) | 257 | await uploadVideo(url, server.accessToken, videoAttributes) |
258 | } else { | 258 | } else { |
259 | exitError(err.message) | 259 | exitError(err.message) |
260 | } | 260 | } |