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-redundancy.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-redundancy.ts')
-rw-r--r-- | server/tools/peertube-redundancy.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts index 76d633f9e..0f6b3086c 100644 --- a/server/tools/peertube-redundancy.ts +++ b/server/tools/peertube-redundancy.ts | |||
@@ -8,7 +8,7 @@ import { URL } from 'url' | |||
8 | import validator from 'validator' | 8 | import validator from 'validator' |
9 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 9 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' |
10 | import { VideoRedundanciesTarget } from '@shared/models' | 10 | import { VideoRedundanciesTarget } from '@shared/models' |
11 | import { buildServer, getAdminTokenOrDie, getServerCredentials } from './cli' | 11 | import { assignToken, buildServer, getServerCredentials } from './cli' |
12 | 12 | ||
13 | import bytes = require('bytes') | 13 | import bytes = require('bytes') |
14 | 14 | ||
@@ -60,8 +60,8 @@ program.parse(process.argv) | |||
60 | 60 | ||
61 | async function listRedundanciesCLI (target: VideoRedundanciesTarget) { | 61 | async function listRedundanciesCLI (target: VideoRedundanciesTarget) { |
62 | const { url, username, password } = await getServerCredentials(program) | 62 | const { url, username, password } = await getServerCredentials(program) |
63 | const token = await getAdminTokenOrDie(url, username, password) | 63 | const server = buildServer(url) |
64 | const server = buildServer(url, token) | 64 | await assignToken(server, username, password) |
65 | 65 | ||
66 | const { data } = await server.redundancyCommand.listVideos({ start: 0, count: 100, sort: 'name', target }) | 66 | const { data } = await server.redundancyCommand.listVideos({ start: 0, count: 100, sort: 'name', target }) |
67 | 67 | ||
@@ -104,8 +104,8 @@ async function listRedundanciesCLI (target: VideoRedundanciesTarget) { | |||
104 | 104 | ||
105 | async function addRedundancyCLI (options: { video: number }, command: Command) { | 105 | async function addRedundancyCLI (options: { video: number }, command: Command) { |
106 | const { url, username, password } = await getServerCredentials(command) | 106 | const { url, username, password } = await getServerCredentials(command) |
107 | const token = await getAdminTokenOrDie(url, username, password) | 107 | const server = buildServer(url) |
108 | const server = buildServer(url, token) | 108 | await assignToken(server, username, password) |
109 | 109 | ||
110 | if (!options.video || validator.isInt('' + options.video) === false) { | 110 | if (!options.video || validator.isInt('' + options.video) === false) { |
111 | console.error('You need to specify the video id to duplicate and it should be a number.\n') | 111 | console.error('You need to specify the video id to duplicate and it should be a number.\n') |
@@ -134,8 +134,8 @@ async function addRedundancyCLI (options: { video: number }, command: Command) { | |||
134 | 134 | ||
135 | async function removeRedundancyCLI (options: { video: number }, command: Command) { | 135 | async function removeRedundancyCLI (options: { video: number }, command: Command) { |
136 | const { url, username, password } = await getServerCredentials(command) | 136 | const { url, username, password } = await getServerCredentials(command) |
137 | const token = await getAdminTokenOrDie(url, username, password) | 137 | const server = buildServer(url) |
138 | const server = buildServer(url, token) | 138 | await assignToken(server, username, password) |
139 | 139 | ||
140 | if (!options.video || validator.isInt('' + options.video) === false) { | 140 | if (!options.video || validator.isInt('' + options.video) === false) { |
141 | console.error('You need to specify the video id to remove from your redundancies.\n') | 141 | console.error('You need to specify the video id to remove from your redundancies.\n') |