aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube-upload.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-09 15:03:44 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit078f17e6d90376050f43ce639e88e11869b49ee7 (patch)
tree1aeef2c43591de2f72b84b85672de8e83815e8fa /server/tools/peertube-upload.ts
parent12edc1495a36b2199f1bf1ba37f50c7b694be382 (diff)
downloadPeerTube-078f17e6d90376050f43ce639e88e11869b49ee7.tar.gz
PeerTube-078f17e6d90376050f43ce639e88e11869b49ee7.tar.zst
PeerTube-078f17e6d90376050f43ce639e88e11869b49ee7.zip
Fix CLI tools
Diffstat (limited to 'server/tools/peertube-upload.ts')
-rw-r--r--server/tools/peertube-upload.ts9
1 files changed, 5 insertions, 4 deletions
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'
6import { isAbsolute } from 'path' 6import { isAbsolute } from 'path'
7import { getAccessToken } from '../../shared/extra-utils' 7import { getAccessToken } from '../../shared/extra-utils'
8import { uploadVideo } from '../../shared/extra-utils/' 8import { uploadVideo } from '../../shared/extra-utils/'
9import { buildCommonVideoOptions, buildVideoAttributesFromCommander, getServerCredentials } from './cli' 9import { buildCommonVideoOptions, buildServer, buildVideoAttributesFromCommander, getServerCredentials } from './cli'
10 10
11let command = program 11let command = program
12 .name('upload') 12 .name('upload')
@@ -46,13 +46,14 @@ getServerCredentials(command)
46 .catch(err => console.error(err)) 46 .catch(err => console.error(err))
47 47
48async function run (url: string, username: string, password: string) { 48async function run (url: string, username: string, password: string) {
49 const accessToken = await getAccessToken(url, username, password) 49 const token = await getAccessToken(url, username, password)
50 const server = buildServer(url, token)
50 51
51 await access(options.file, constants.F_OK) 52 await access(options.file, constants.F_OK)
52 53
53 console.log('Uploading %s video...', options.videoName) 54 console.log('Uploading %s video...', options.videoName)
54 55
55 const videoAttributes = await buildVideoAttributesFromCommander(url, program) 56 const videoAttributes = await buildVideoAttributesFromCommander(server, program)
56 57
57 Object.assign(videoAttributes, { 58 Object.assign(videoAttributes, {
58 fixture: options.file, 59 fixture: options.file,
@@ -61,7 +62,7 @@ async function run (url: string, username: string, password: string) {
61 }) 62 })
62 63
63 try { 64 try {
64 await uploadVideo(url, accessToken, videoAttributes) 65 await uploadVideo(url, token, videoAttributes)
65 console.log(`Video ${options.videoName} uploaded.`) 66 console.log(`Video ${options.videoName} uploaded.`)
66 process.exit(0) 67 process.exit(0)
67 } catch (err) { 68 } catch (err) {