From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tools/cli.ts | 10 +++++----- server/tools/peertube-import-videos.ts | 10 +++++----- server/tools/peertube-plugins.ts | 8 ++++---- server/tools/peertube-redundancy.ts | 10 +++++----- server/tools/peertube-upload.ts | 2 +- server/tools/test-live.ts | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) (limited to 'server/tools') diff --git a/server/tools/cli.ts b/server/tools/cli.ts index 163ed62d1..7d5eb72ed 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts @@ -15,8 +15,8 @@ const config = require('application-config')(configName) const version = require('../../../package.json').version async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) { - const token = await server.loginCommand.getAccessToken(username, password) - const me = await server.usersCommand.getMyInfo({ token }) + const token = await server.login.getAccessToken(username, password) + const me = await server.users.getMyInfo({ token }) if (me.role !== UserRole.ADMINISTRATOR) { console.error('You must be an administrator.') @@ -160,7 +160,7 @@ async function buildVideoAttributesFromCommander (server: ServerInfo, command: C Object.assign(videoAttributes, booleanAttributes) if (options.channelName) { - const videoChannel = await server.channelsCommand.get({ channelName: options.channelName }) + const videoChannel = await server.channels.get({ channelName: options.channelName }) Object.assign(videoAttributes, { channelId: videoChannel.id }) @@ -187,10 +187,10 @@ function buildServer (url: string): ServerInfo { } async function assignToken (server: ServerInfo, username: string, password: string) { - const bodyClient = await server.loginCommand.getClient() + const bodyClient = await server.login.getClient() const client = { id: bodyClient.client_id, secret: bodyClient.client_secret } - const body = await server.loginCommand.login({ client, user: { username, password } }) + const body = await server.login.login({ client, user: { username, password } }) server.accessToken = body.access_token } diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index fc76735b9..caf1facc7 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -150,7 +150,7 @@ async function processVideo (parameters: { } const server = buildServer(url) - const { data } = await server.searchCommand.advancedVideoSearch({ + const { data } = await server.search.advancedVideoSearch({ search: { search: videoInfo.title, sort: '-match', @@ -249,14 +249,14 @@ async function uploadVideoOnPeerTube (parameters: { log.info('\nUploading on PeerTube video "%s".', attributes.name) try { - await server.videosCommand.upload({ attributes }) + await server.videos.upload({ attributes }) } catch (err) { if (err.message.indexOf('401') !== -1) { log.info('Got 401 Unauthorized, token may have expired, renewing token and retry.') - server.accessToken = await server.loginCommand.getAccessToken(username, password) + server.accessToken = await server.login.getAccessToken(username, password) - await server.videosCommand.upload({ attributes }) + await server.videos.upload({ attributes }) } else { exitError(err.message) } @@ -277,7 +277,7 @@ async function getCategory (server: ServerInfo, categories: string[]) { if (categoryString === 'News & Politics') return 11 - const categoriesServer = await server.videosCommand.getCategories() + const categoriesServer = await server.videos.getCategories() for (const key of Object.keys(categoriesServer)) { const categoryServer = categoriesServer[key] diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts index 22a09b779..d9c285115 100644 --- a/server/tools/peertube-plugins.ts +++ b/server/tools/peertube-plugins.ts @@ -69,7 +69,7 @@ async function pluginsListCLI (command: Command, options: OptionValues) { if (options.onlyThemes) pluginType = PluginType.THEME if (options.onlyPlugins) pluginType = PluginType.PLUGIN - const { data } = await server.pluginsCommand.list({ start: 0, count: 100, sort: 'name', pluginType }) + const { data } = await server.plugins.list({ start: 0, count: 100, sort: 'name', pluginType }) const table = new CliTable3({ head: [ 'name', 'version', 'homepage' ], @@ -109,7 +109,7 @@ async function installPluginCLI (command: Command, options: OptionValues) { await assignToken(server, username, password) try { - await server.pluginsCommand.install({ npmName: options.npmName, path: options.path }) + await server.plugins.install({ npmName: options.npmName, path: options.path }) } catch (err) { console.error('Cannot install plugin.', err) process.exit(-1) @@ -136,7 +136,7 @@ async function updatePluginCLI (command: Command, options: OptionValues) { await assignToken(server, username, password) try { - await server.pluginsCommand.update({ npmName: options.npmName, path: options.path }) + await server.plugins.update({ npmName: options.npmName, path: options.path }) } catch (err) { console.error('Cannot update plugin.', err) process.exit(-1) @@ -158,7 +158,7 @@ async function uninstallPluginCLI (command: Command, options: OptionValues) { await assignToken(server, username, password) try { - await server.pluginsCommand.uninstall({ npmName: options.npmName }) + await server.plugins.uninstall({ npmName: options.npmName }) } catch (err) { console.error('Cannot uninstall plugin.', err) process.exit(-1) diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts index 0f6b3086c..5fda68c8e 100644 --- a/server/tools/peertube-redundancy.ts +++ b/server/tools/peertube-redundancy.ts @@ -63,7 +63,7 @@ async function listRedundanciesCLI (target: VideoRedundanciesTarget) { const server = buildServer(url) await assignToken(server, username, password) - const { data } = await server.redundancyCommand.listVideos({ start: 0, count: 100, sort: 'name', target }) + const { data } = await server.redundancy.listVideos({ start: 0, count: 100, sort: 'name', target }) const table = new CliTable3({ head: [ 'video id', 'video name', 'video url', 'files', 'playlists', 'by instances', 'total size' ] @@ -114,7 +114,7 @@ async function addRedundancyCLI (options: { video: number }, command: Command) { } try { - await server.redundancyCommand.addVideo({ videoId: options.video }) + await server.redundancy.addVideo({ videoId: options.video }) console.log('Video will be duplicated by your instance!') @@ -145,11 +145,11 @@ async function removeRedundancyCLI (options: { video: number }, command: Command const videoId = parseInt(options.video + '', 10) - const myVideoRedundancies = await server.redundancyCommand.listVideos({ target: 'my-videos' }) + const myVideoRedundancies = await server.redundancy.listVideos({ target: 'my-videos' }) let videoRedundancy = myVideoRedundancies.data.find(r => videoId === r.id) if (!videoRedundancy) { - const remoteVideoRedundancies = await server.redundancyCommand.listVideos({ target: 'remote-videos' }) + const remoteVideoRedundancies = await server.redundancy.listVideos({ target: 'remote-videos' }) videoRedundancy = remoteVideoRedundancies.data.find(r => videoId === r.id) } @@ -164,7 +164,7 @@ async function removeRedundancyCLI (options: { video: number }, command: Command .map(r => r.id) for (const id of ids) { - await server.redundancyCommand.removeVideo({ redundancyId: id }) + await server.redundancy.removeVideo({ redundancyId: id }) } console.log('Video redundancy removed!') diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index 597137e4c..01fb1fe8d 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts @@ -62,7 +62,7 @@ async function run (url: string, username: string, password: string) { } try { - await server.videosCommand.upload({ attributes }) + await server.videos.upload({ attributes }) console.log(`Video ${options.videoName} uploaded.`) process.exit(0) } catch (err) { diff --git a/server/tools/test-live.ts b/server/tools/test-live.ts index 7004e98e8..bc31b6926 100644 --- a/server/tools/test-live.ts +++ b/server/tools/test-live.ts @@ -54,15 +54,15 @@ async function run () { const attributes: LiveVideoCreate = { name: 'live', saveReplay: true, - channelId: server.videoChannel.id, + channelId: server.store.channel.id, privacy: VideoPrivacy.PUBLIC } console.log('Creating live.') - const { uuid: liveVideoUUID } = await server.liveCommand.create({ fields: attributes }) + const { uuid: liveVideoUUID } = await server.live.create({ fields: attributes }) - const live = await server.liveCommand.get({ videoId: liveVideoUUID }) + const live = await server.live.get({ videoId: liveVideoUUID }) console.log('Sending RTMP stream.') @@ -82,7 +82,7 @@ async function run () { // ---------------------------------------------------------------------------- async function buildConfig (server: ServerInfo, commandType: CommandType) { - await server.configCommand.updateCustomSubConfig({ + await server.config.updateCustomSubConfig({ newConfig: { instance: { customizations: { -- cgit v1.2.3