]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/real-world/tools/upload-directory.js
3 const program
= require('commander')
4 const eachSeries
= require('async/eachSeries')
5 const exec
= require('child_process').exec
6 const fs
= require('fs')
7 const path
= require('path')
10 .option('-u, --url <url>', 'Server url')
11 .option('-n, --username <username>', 'Username')
12 .option('-p, --password <token>', 'Password')
13 .option('-i, --directory <directory>', 'Videos directory absolute path')
14 .option('-d, --description <description>', 'Video description')
15 .option('-t, --tags <tags>', 'Video tags', list
)
23 !program
.description
||
26 throw new Error('All arguments are required.')
29 exec('node ./get-access-token -u "' + program
.url
+ '" -n "' + program
.username
+ '" -p "' + program
.password
+ '"', function (err
, stdout
) {
32 const accessToken
= stdout
.replace('\n', '')
34 fs
.readdir(program
.directory
, function (err
, files
) {
37 eachSeries(files
, function (file
, callbackEach
) {
41 description: program
.description
44 let command
= 'node ./upload'
45 command
+= ' -u "' + program
.url
+ '"'
46 command
+= ' -a "' + accessToken
+ '"'
47 command
+= ' -n "' + video
.name
+ '"'
48 command
+= ' -d "' + video
.description
+ '"'
49 command
+= ' -t "' + video
.tags
.join(',') + '"'
50 command
+= ' -f "' + path
.join(program
.directory
, file
) + '"'
52 exec(command
, function (err
, stdout
) {
53 if (err
) console
.log(err
)
63 // ----------------------------------------------------------------------------