diff options
Diffstat (limited to 'server/tools')
-rw-r--r-- | server/tools/cli.ts | 10 | ||||
-rw-r--r-- | server/tools/peertube-import-videos.ts | 10 | ||||
-rw-r--r-- | server/tools/peertube-plugins.ts | 8 | ||||
-rw-r--r-- | server/tools/peertube-redundancy.ts | 10 | ||||
-rw-r--r-- | server/tools/peertube-upload.ts | 2 | ||||
-rw-r--r-- | server/tools/test-live.ts | 8 |
6 files changed, 24 insertions, 24 deletions
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) | |||
15 | const version = require('../../../package.json').version | 15 | const version = require('../../../package.json').version |
16 | 16 | ||
17 | async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) { | 17 | async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) { |
18 | const token = await server.loginCommand.getAccessToken(username, password) | 18 | const token = await server.login.getAccessToken(username, password) |
19 | const me = await server.usersCommand.getMyInfo({ token }) | 19 | const me = await server.users.getMyInfo({ token }) |
20 | 20 | ||
21 | if (me.role !== UserRole.ADMINISTRATOR) { | 21 | if (me.role !== UserRole.ADMINISTRATOR) { |
22 | console.error('You must be an administrator.') | 22 | console.error('You must be an administrator.') |
@@ -160,7 +160,7 @@ async function buildVideoAttributesFromCommander (server: ServerInfo, command: C | |||
160 | Object.assign(videoAttributes, booleanAttributes) | 160 | Object.assign(videoAttributes, booleanAttributes) |
161 | 161 | ||
162 | if (options.channelName) { | 162 | if (options.channelName) { |
163 | const videoChannel = await server.channelsCommand.get({ channelName: options.channelName }) | 163 | const videoChannel = await server.channels.get({ channelName: options.channelName }) |
164 | 164 | ||
165 | Object.assign(videoAttributes, { channelId: videoChannel.id }) | 165 | Object.assign(videoAttributes, { channelId: videoChannel.id }) |
166 | 166 | ||
@@ -187,10 +187,10 @@ function buildServer (url: string): ServerInfo { | |||
187 | } | 187 | } |
188 | 188 | ||
189 | async function assignToken (server: ServerInfo, username: string, password: string) { | 189 | async function assignToken (server: ServerInfo, username: string, password: string) { |
190 | const bodyClient = await server.loginCommand.getClient() | 190 | const bodyClient = await server.login.getClient() |
191 | const client = { id: bodyClient.client_id, secret: bodyClient.client_secret } | 191 | const client = { id: bodyClient.client_id, secret: bodyClient.client_secret } |
192 | 192 | ||
193 | const body = await server.loginCommand.login({ client, user: { username, password } }) | 193 | const body = await server.login.login({ client, user: { username, password } }) |
194 | 194 | ||
195 | server.accessToken = body.access_token | 195 | server.accessToken = body.access_token |
196 | } | 196 | } |
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: { | |||
150 | } | 150 | } |
151 | 151 | ||
152 | const server = buildServer(url) | 152 | const server = buildServer(url) |
153 | const { data } = await server.searchCommand.advancedVideoSearch({ | 153 | const { data } = await server.search.advancedVideoSearch({ |
154 | search: { | 154 | search: { |
155 | search: videoInfo.title, | 155 | search: videoInfo.title, |
156 | sort: '-match', | 156 | sort: '-match', |
@@ -249,14 +249,14 @@ async function uploadVideoOnPeerTube (parameters: { | |||
249 | log.info('\nUploading on PeerTube video "%s".', attributes.name) | 249 | log.info('\nUploading on PeerTube video "%s".', attributes.name) |
250 | 250 | ||
251 | try { | 251 | try { |
252 | await server.videosCommand.upload({ attributes }) | 252 | await server.videos.upload({ attributes }) |
253 | } catch (err) { | 253 | } catch (err) { |
254 | if (err.message.indexOf('401') !== -1) { | 254 | if (err.message.indexOf('401') !== -1) { |
255 | log.info('Got 401 Unauthorized, token may have expired, renewing token and retry.') | 255 | log.info('Got 401 Unauthorized, token may have expired, renewing token and retry.') |
256 | 256 | ||
257 | server.accessToken = await server.loginCommand.getAccessToken(username, password) | 257 | server.accessToken = await server.login.getAccessToken(username, password) |
258 | 258 | ||
259 | await server.videosCommand.upload({ attributes }) | 259 | await server.videos.upload({ attributes }) |
260 | } else { | 260 | } else { |
261 | exitError(err.message) | 261 | exitError(err.message) |
262 | } | 262 | } |
@@ -277,7 +277,7 @@ async function getCategory (server: ServerInfo, categories: string[]) { | |||
277 | 277 | ||
278 | if (categoryString === 'News & Politics') return 11 | 278 | if (categoryString === 'News & Politics') return 11 |
279 | 279 | ||
280 | const categoriesServer = await server.videosCommand.getCategories() | 280 | const categoriesServer = await server.videos.getCategories() |
281 | 281 | ||
282 | for (const key of Object.keys(categoriesServer)) { | 282 | for (const key of Object.keys(categoriesServer)) { |
283 | const categoryServer = categoriesServer[key] | 283 | 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) { | |||
69 | if (options.onlyThemes) pluginType = PluginType.THEME | 69 | if (options.onlyThemes) pluginType = PluginType.THEME |
70 | if (options.onlyPlugins) pluginType = PluginType.PLUGIN | 70 | if (options.onlyPlugins) pluginType = PluginType.PLUGIN |
71 | 71 | ||
72 | const { data } = await server.pluginsCommand.list({ start: 0, count: 100, sort: 'name', pluginType }) | 72 | const { data } = await server.plugins.list({ start: 0, count: 100, sort: 'name', pluginType }) |
73 | 73 | ||
74 | const table = new CliTable3({ | 74 | const table = new CliTable3({ |
75 | head: [ 'name', 'version', 'homepage' ], | 75 | head: [ 'name', 'version', 'homepage' ], |
@@ -109,7 +109,7 @@ async function installPluginCLI (command: Command, options: OptionValues) { | |||
109 | await assignToken(server, username, password) | 109 | await assignToken(server, username, password) |
110 | 110 | ||
111 | try { | 111 | try { |
112 | await server.pluginsCommand.install({ npmName: options.npmName, path: options.path }) | 112 | await server.plugins.install({ npmName: options.npmName, path: options.path }) |
113 | } catch (err) { | 113 | } catch (err) { |
114 | console.error('Cannot install plugin.', err) | 114 | console.error('Cannot install plugin.', err) |
115 | process.exit(-1) | 115 | process.exit(-1) |
@@ -136,7 +136,7 @@ async function updatePluginCLI (command: Command, options: OptionValues) { | |||
136 | await assignToken(server, username, password) | 136 | await assignToken(server, username, password) |
137 | 137 | ||
138 | try { | 138 | try { |
139 | await server.pluginsCommand.update({ npmName: options.npmName, path: options.path }) | 139 | await server.plugins.update({ npmName: options.npmName, path: options.path }) |
140 | } catch (err) { | 140 | } catch (err) { |
141 | console.error('Cannot update plugin.', err) | 141 | console.error('Cannot update plugin.', err) |
142 | process.exit(-1) | 142 | process.exit(-1) |
@@ -158,7 +158,7 @@ async function uninstallPluginCLI (command: Command, options: OptionValues) { | |||
158 | await assignToken(server, username, password) | 158 | await assignToken(server, username, password) |
159 | 159 | ||
160 | try { | 160 | try { |
161 | await server.pluginsCommand.uninstall({ npmName: options.npmName }) | 161 | await server.plugins.uninstall({ npmName: options.npmName }) |
162 | } catch (err) { | 162 | } catch (err) { |
163 | console.error('Cannot uninstall plugin.', err) | 163 | console.error('Cannot uninstall plugin.', err) |
164 | process.exit(-1) | 164 | 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) { | |||
63 | const server = buildServer(url) | 63 | const server = buildServer(url) |
64 | await assignToken(server, username, password) | 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.redundancy.listVideos({ start: 0, count: 100, sort: 'name', target }) |
67 | 67 | ||
68 | const table = new CliTable3({ | 68 | const table = new CliTable3({ |
69 | head: [ 'video id', 'video name', 'video url', 'files', 'playlists', 'by instances', 'total size' ] | 69 | 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) { | |||
114 | } | 114 | } |
115 | 115 | ||
116 | try { | 116 | try { |
117 | await server.redundancyCommand.addVideo({ videoId: options.video }) | 117 | await server.redundancy.addVideo({ videoId: options.video }) |
118 | 118 | ||
119 | console.log('Video will be duplicated by your instance!') | 119 | console.log('Video will be duplicated by your instance!') |
120 | 120 | ||
@@ -145,11 +145,11 @@ async function removeRedundancyCLI (options: { video: number }, command: Command | |||
145 | 145 | ||
146 | const videoId = parseInt(options.video + '', 10) | 146 | const videoId = parseInt(options.video + '', 10) |
147 | 147 | ||
148 | const myVideoRedundancies = await server.redundancyCommand.listVideos({ target: 'my-videos' }) | 148 | const myVideoRedundancies = await server.redundancy.listVideos({ target: 'my-videos' }) |
149 | let videoRedundancy = myVideoRedundancies.data.find(r => videoId === r.id) | 149 | let videoRedundancy = myVideoRedundancies.data.find(r => videoId === r.id) |
150 | 150 | ||
151 | if (!videoRedundancy) { | 151 | if (!videoRedundancy) { |
152 | const remoteVideoRedundancies = await server.redundancyCommand.listVideos({ target: 'remote-videos' }) | 152 | const remoteVideoRedundancies = await server.redundancy.listVideos({ target: 'remote-videos' }) |
153 | videoRedundancy = remoteVideoRedundancies.data.find(r => videoId === r.id) | 153 | videoRedundancy = remoteVideoRedundancies.data.find(r => videoId === r.id) |
154 | } | 154 | } |
155 | 155 | ||
@@ -164,7 +164,7 @@ async function removeRedundancyCLI (options: { video: number }, command: Command | |||
164 | .map(r => r.id) | 164 | .map(r => r.id) |
165 | 165 | ||
166 | for (const id of ids) { | 166 | for (const id of ids) { |
167 | await server.redundancyCommand.removeVideo({ redundancyId: id }) | 167 | await server.redundancy.removeVideo({ redundancyId: id }) |
168 | } | 168 | } |
169 | 169 | ||
170 | console.log('Video redundancy removed!') | 170 | 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) { | |||
62 | } | 62 | } |
63 | 63 | ||
64 | try { | 64 | try { |
65 | await server.videosCommand.upload({ attributes }) | 65 | await server.videos.upload({ attributes }) |
66 | console.log(`Video ${options.videoName} uploaded.`) | 66 | console.log(`Video ${options.videoName} uploaded.`) |
67 | process.exit(0) | 67 | process.exit(0) |
68 | } catch (err) { | 68 | } 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 () { | |||
54 | const attributes: LiveVideoCreate = { | 54 | const attributes: LiveVideoCreate = { |
55 | name: 'live', | 55 | name: 'live', |
56 | saveReplay: true, | 56 | saveReplay: true, |
57 | channelId: server.videoChannel.id, | 57 | channelId: server.store.channel.id, |
58 | privacy: VideoPrivacy.PUBLIC | 58 | privacy: VideoPrivacy.PUBLIC |
59 | } | 59 | } |
60 | 60 | ||
61 | console.log('Creating live.') | 61 | console.log('Creating live.') |
62 | 62 | ||
63 | const { uuid: liveVideoUUID } = await server.liveCommand.create({ fields: attributes }) | 63 | const { uuid: liveVideoUUID } = await server.live.create({ fields: attributes }) |
64 | 64 | ||
65 | const live = await server.liveCommand.get({ videoId: liveVideoUUID }) | 65 | const live = await server.live.get({ videoId: liveVideoUUID }) |
66 | 66 | ||
67 | console.log('Sending RTMP stream.') | 67 | console.log('Sending RTMP stream.') |
68 | 68 | ||
@@ -82,7 +82,7 @@ async function run () { | |||
82 | // ---------------------------------------------------------------------------- | 82 | // ---------------------------------------------------------------------------- |
83 | 83 | ||
84 | async function buildConfig (server: ServerInfo, commandType: CommandType) { | 84 | async function buildConfig (server: ServerInfo, commandType: CommandType) { |
85 | await server.configCommand.updateCustomSubConfig({ | 85 | await server.config.updateCustomSubConfig({ |
86 | newConfig: { | 86 | newConfig: { |
87 | instance: { | 87 | instance: { |
88 | customizations: { | 88 | customizations: { |