diff options
Diffstat (limited to 'server/tests/real-world/tools/upload.js')
-rw-r--r-- | server/tests/real-world/tools/upload.js | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/server/tests/real-world/tools/upload.js b/server/tests/real-world/tools/upload.js deleted file mode 100644 index efb91e228..000000000 --- a/server/tests/real-world/tools/upload.js +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const program = require('commander') | ||
4 | const fs = require('fs') | ||
5 | |||
6 | const utils = require('../../utils/videos') | ||
7 | |||
8 | program | ||
9 | .option('-u, --url <url>', 'Server url') | ||
10 | .option('-a, --access-token <token>', 'Access token') | ||
11 | .option('-n, --name <name>', 'Video name') | ||
12 | .option('-x, --nsfw', 'Video is Not Safe For Work') | ||
13 | .option('-c, --category <category number>', 'Category number') | ||
14 | .option('-l, --licence <licence number>', 'Licence number') | ||
15 | .option('-g, --language <language number>', 'Language number') | ||
16 | .option('-d, --description <description>', 'Video description') | ||
17 | .option('-t, --tags <tags>', 'Video tags', list) | ||
18 | .option('-f, --file <file>', 'Video absolute file path') | ||
19 | .parse(process.argv) | ||
20 | |||
21 | if ( | ||
22 | !program.url || | ||
23 | !program.accessToken || | ||
24 | !program.name || | ||
25 | !program.category || | ||
26 | !program.licence || | ||
27 | !program.language || | ||
28 | !program.nsfw || | ||
29 | !program.description || | ||
30 | !program.tags || | ||
31 | !Array.isArray(program.tags) || | ||
32 | program.tags.length === 0 || | ||
33 | !program.file | ||
34 | ) { | ||
35 | throw new Error('All arguments are required.') | ||
36 | } | ||
37 | |||
38 | fs.access(program.file, fs.F_OK, function (err) { | ||
39 | if (err) throw err | ||
40 | |||
41 | upload( | ||
42 | program.url, | ||
43 | program.accessToken, | ||
44 | program.name, | ||
45 | program.category, | ||
46 | program.licence, | ||
47 | program.language, | ||
48 | program.nsfw, | ||
49 | program.description, | ||
50 | program.tags, | ||
51 | program.file | ||
52 | ) | ||
53 | }) | ||
54 | |||
55 | // ---------------------------------------------------------------------------- | ||
56 | |||
57 | function list (val) { | ||
58 | return val.split(',') | ||
59 | } | ||
60 | |||
61 | function upload (url, accessToken, name, category, licence, language, nsfw, description, tags, fixture) { | ||
62 | console.log('Uploading %s video...', program.name) | ||
63 | |||
64 | const videoAttributes = { | ||
65 | name, | ||
66 | category, | ||
67 | licence, | ||
68 | language, | ||
69 | nsfw, | ||
70 | description, | ||
71 | tags, | ||
72 | fixture | ||
73 | } | ||
74 | utils.uploadVideo(url, accessToken, videoAttributes, function (err) { | ||
75 | if (err) throw err | ||
76 | |||
77 | console.log('Video uploaded.') | ||
78 | }) | ||
79 | } | ||