From 078f17e6d90376050f43ce639e88e11869b49ee7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 15:03:44 +0200 Subject: Fix CLI tools --- server/tools/peertube-upload.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'server/tools/peertube-upload.ts') diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index 02edbd809..d1c5348d1 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts @@ -6,7 +6,7 @@ import { access, constants } from 'fs-extra' import { isAbsolute } from 'path' import { getAccessToken } from '../../shared/extra-utils' import { uploadVideo } from '../../shared/extra-utils/' -import { buildCommonVideoOptions, buildVideoAttributesFromCommander, getServerCredentials } from './cli' +import { buildCommonVideoOptions, buildServer, buildVideoAttributesFromCommander, getServerCredentials } from './cli' let command = program .name('upload') @@ -46,13 +46,14 @@ getServerCredentials(command) .catch(err => console.error(err)) async function run (url: string, username: string, password: string) { - const accessToken = await getAccessToken(url, username, password) + const token = await getAccessToken(url, username, password) + const server = buildServer(url, token) await access(options.file, constants.F_OK) console.log('Uploading %s video...', options.videoName) - const videoAttributes = await buildVideoAttributesFromCommander(url, program) + const videoAttributes = await buildVideoAttributesFromCommander(server, program) Object.assign(videoAttributes, { fixture: options.file, @@ -61,7 +62,7 @@ async function run (url: string, username: string, password: string) { }) try { - await uploadVideo(url, accessToken, videoAttributes) + await uploadVideo(url, token, videoAttributes) console.log(`Video ${options.videoName} uploaded.`) process.exit(0) } catch (err) { -- cgit v1.2.3 From d0a0fa429d4651710ed951a3c11af0219e408964 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 11:44:16 +0200 Subject: Adapt CLI to new commands --- server/tools/peertube-upload.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'server/tools/peertube-upload.ts') diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index d1c5348d1..c94b05857 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts @@ -4,9 +4,8 @@ registerTSPaths() import { program } from 'commander' import { access, constants } from 'fs-extra' import { isAbsolute } from 'path' -import { getAccessToken } from '../../shared/extra-utils' import { uploadVideo } from '../../shared/extra-utils/' -import { buildCommonVideoOptions, buildServer, buildVideoAttributesFromCommander, getServerCredentials } from './cli' +import { assignToken, buildCommonVideoOptions, buildServer, buildVideoAttributesFromCommander, getServerCredentials } from './cli' let command = program .name('upload') @@ -46,8 +45,8 @@ getServerCredentials(command) .catch(err => console.error(err)) async function run (url: string, username: string, password: string) { - const token = await getAccessToken(url, username, password) - const server = buildServer(url, token) + const server = buildServer(url) + await assignToken(server, username, password) await access(options.file, constants.F_OK) @@ -62,7 +61,7 @@ async function run (url: string, username: string, password: string) { }) try { - await uploadVideo(url, token, videoAttributes) + await uploadVideo(url, server.accessToken, videoAttributes) console.log(`Video ${options.videoName} uploaded.`) process.exit(0) } catch (err) { -- cgit v1.2.3 From d23dd9fbfc4d26026352c10f81d2795ceaf2908a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Jul 2021 10:02:54 +0200 Subject: Introduce videos command --- server/tools/peertube-upload.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'server/tools/peertube-upload.ts') diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index c94b05857..597137e4c 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts @@ -4,7 +4,6 @@ registerTSPaths() import { program } from 'commander' import { access, constants } from 'fs-extra' import { isAbsolute } from 'path' -import { uploadVideo } from '../../shared/extra-utils/' import { assignToken, buildCommonVideoOptions, buildServer, buildVideoAttributesFromCommander, getServerCredentials } from './cli' let command = program @@ -52,16 +51,18 @@ async function run (url: string, username: string, password: string) { console.log('Uploading %s video...', options.videoName) - const videoAttributes = await buildVideoAttributesFromCommander(server, program) + const baseAttributes = await buildVideoAttributesFromCommander(server, program) + + const attributes = { + ...baseAttributes, - Object.assign(videoAttributes, { fixture: options.file, thumbnailfile: options.thumbnail, previewfile: options.preview - }) + } try { - await uploadVideo(url, server.accessToken, videoAttributes) + await server.videosCommand.upload({ attributes }) console.log(`Video ${options.videoName} uploaded.`) process.exit(0) } catch (err) { -- cgit v1.2.3 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/peertube-upload.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tools/peertube-upload.ts') 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) { -- cgit v1.2.3