aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube-upload.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools/peertube-upload.ts')
-rw-r--r--server/tools/peertube-upload.ts22
1 files changed, 12 insertions, 10 deletions
diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts
index 8de952e7b..86c7f3d91 100644
--- a/server/tools/peertube-upload.ts
+++ b/server/tools/peertube-upload.ts
@@ -22,16 +22,18 @@ command
22 .option('-f, --file <file>', 'Video absolute file path') 22 .option('-f, --file <file>', 'Video absolute file path')
23 .parse(process.argv) 23 .parse(process.argv)
24 24
25const options = command.opts()
26
25getServerCredentials(command) 27getServerCredentials(command)
26 .then(({ url, username, password }) => { 28 .then(({ url, username, password }) => {
27 if (!program['videoName'] || !program['file']) { 29 if (!options.videoName || !options.file) {
28 if (!program['videoName']) console.error('--video-name is required.') 30 if (!options.videoName) console.error('--video-name is required.')
29 if (!program['file']) console.error('--file is required.') 31 if (!options.file) console.error('--file is required.')
30 32
31 process.exit(-1) 33 process.exit(-1)
32 } 34 }
33 35
34 if (isAbsolute(program['file']) === false) { 36 if (isAbsolute(options.file) === false) {
35 console.error('File path should be absolute.') 37 console.error('File path should be absolute.')
36 process.exit(-1) 38 process.exit(-1)
37 } 39 }
@@ -46,21 +48,21 @@ getServerCredentials(command)
46async function run (url: string, username: string, password: string) { 48async function run (url: string, username: string, password: string) {
47 const accessToken = await getAccessToken(url, username, password) 49 const accessToken = await getAccessToken(url, username, password)
48 50
49 await access(program['file'], constants.F_OK) 51 await access(options.file, constants.F_OK)
50 52
51 console.log('Uploading %s video...', program['videoName']) 53 console.log('Uploading %s video...', options.videoName)
52 54
53 const videoAttributes = await buildVideoAttributesFromCommander(url, program) 55 const videoAttributes = await buildVideoAttributesFromCommander(url, program)
54 56
55 Object.assign(videoAttributes, { 57 Object.assign(videoAttributes, {
56 fixture: program['file'], 58 fixture: options.file,
57 thumbnailfile: program['thumbnail'], 59 thumbnailfile: options.thumbnail,
58 previewfile: program['preview'] 60 previewfile: options.preview
59 }) 61 })
60 62
61 try { 63 try {
62 await uploadVideo(url, accessToken, videoAttributes) 64 await uploadVideo(url, accessToken, videoAttributes)
63 console.log(`Video ${program['videoName']} uploaded.`) 65 console.log(`Video ${options.videoName} uploaded.`)
64 process.exit(0) 66 process.exit(0)
65 } catch (err) { 67 } catch (err) {
66 console.error(require('util').inspect(err)) 68 console.error(require('util').inspect(err))