diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/create-import-video-file-job.ts | 8 | ||||
-rwxr-xr-x | scripts/create-transcoding-job.ts | 18 | ||||
-rwxr-xr-x | scripts/parse-log.ts | 10 | ||||
-rwxr-xr-x | scripts/plugin/install.ts | 10 | ||||
-rwxr-xr-x | scripts/plugin/uninstall.ts | 6 | ||||
-rwxr-xr-x | scripts/reset-password.ts | 8 |
6 files changed, 36 insertions, 24 deletions
diff --git a/scripts/create-import-video-file-job.ts b/scripts/create-import-video-file-job.ts index d71e82c14..f5271c7a3 100644 --- a/scripts/create-import-video-file-job.ts +++ b/scripts/create-import-video-file-job.ts | |||
@@ -13,7 +13,9 @@ program | |||
13 | .description('Import a video file to replace an already uploaded file or to add a new resolution') | 13 | .description('Import a video file to replace an already uploaded file or to add a new resolution') |
14 | .parse(process.argv) | 14 | .parse(process.argv) |
15 | 15 | ||
16 | if (program['video'] === undefined || program['import'] === undefined) { | 16 | const options = program.opts() |
17 | |||
18 | if (options.video === undefined || options.import === undefined) { | ||
17 | console.error('All parameters are mandatory.') | 19 | console.error('All parameters are mandatory.') |
18 | process.exit(-1) | 20 | process.exit(-1) |
19 | } | 21 | } |
@@ -28,13 +30,13 @@ run() | |||
28 | async function run () { | 30 | async function run () { |
29 | await initDatabaseModels(true) | 31 | await initDatabaseModels(true) |
30 | 32 | ||
31 | const video = await VideoModel.loadByUUID(program['video']) | 33 | const video = await VideoModel.loadByUUID(options.video) |
32 | if (!video) throw new Error('Video not found.') | 34 | if (!video) throw new Error('Video not found.') |
33 | if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.') | 35 | if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.') |
34 | 36 | ||
35 | const dataInput = { | 37 | const dataInput = { |
36 | videoUUID: video.uuid, | 38 | videoUUID: video.uuid, |
37 | filePath: resolve(program['import']) | 39 | filePath: resolve(options.import) |
38 | } | 40 | } |
39 | 41 | ||
40 | await JobQueue.Instance.init() | 42 | await JobQueue.Instance.init() |
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index ca9e2a99a..eb620aeca 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts | |||
@@ -14,12 +14,14 @@ program | |||
14 | .option('--generate-hls', 'Generate HLS playlist') | 14 | .option('--generate-hls', 'Generate HLS playlist') |
15 | .parse(process.argv) | 15 | .parse(process.argv) |
16 | 16 | ||
17 | if (program['video'] === undefined) { | 17 | const options = program.opts() |
18 | |||
19 | if (options.video === undefined) { | ||
18 | console.error('All parameters are mandatory.') | 20 | console.error('All parameters are mandatory.') |
19 | process.exit(-1) | 21 | process.exit(-1) |
20 | } | 22 | } |
21 | 23 | ||
22 | if (program.resolution !== undefined && Number.isNaN(+program.resolution)) { | 24 | if (options.resolution !== undefined && Number.isNaN(+options.resolution)) { |
23 | console.error('The resolution must be an integer (example: 1080).') | 25 | console.error('The resolution must be an integer (example: 1080).') |
24 | process.exit(-1) | 26 | process.exit(-1) |
25 | } | 27 | } |
@@ -34,15 +36,15 @@ run() | |||
34 | async function run () { | 36 | async function run () { |
35 | await initDatabaseModels(true) | 37 | await initDatabaseModels(true) |
36 | 38 | ||
37 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(program['video']) | 39 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.video) |
38 | if (!video) throw new Error('Video not found.') | 40 | if (!video) throw new Error('Video not found.') |
39 | 41 | ||
40 | const dataInput: VideoTranscodingPayload[] = [] | 42 | const dataInput: VideoTranscodingPayload[] = [] |
41 | const { videoFileResolution } = await video.getMaxQualityResolution() | 43 | const { videoFileResolution } = await video.getMaxQualityResolution() |
42 | 44 | ||
43 | if (program.generateHls) { | 45 | if (options.generateHls) { |
44 | const resolutionsEnabled = program.resolution | 46 | const resolutionsEnabled = options.resolution |
45 | ? [ program.resolution ] | 47 | ? [ options.resolution ] |
46 | : computeResolutionsToTranscode(videoFileResolution, 'vod').concat([ videoFileResolution ]) | 48 | : computeResolutionsToTranscode(videoFileResolution, 'vod').concat([ videoFileResolution ]) |
47 | 49 | ||
48 | for (const resolution of resolutionsEnabled) { | 50 | for (const resolution of resolutionsEnabled) { |
@@ -54,12 +56,12 @@ async function run () { | |||
54 | copyCodecs: false | 56 | copyCodecs: false |
55 | }) | 57 | }) |
56 | } | 58 | } |
57 | } else if (program.resolution !== undefined) { | 59 | } else if (options.resolution !== undefined) { |
58 | dataInput.push({ | 60 | dataInput.push({ |
59 | type: 'new-resolution-to-webtorrent', | 61 | type: 'new-resolution-to-webtorrent', |
60 | videoUUID: video.uuid, | 62 | videoUUID: video.uuid, |
61 | isNewVideo: false, | 63 | isNewVideo: false, |
62 | resolution: program.resolution | 64 | resolution: options.resolution |
63 | }) | 65 | }) |
64 | } else { | 66 | } else { |
65 | dataInput.push({ | 67 | dataInput.push({ |
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts index 045348e86..3679dab74 100755 --- a/scripts/parse-log.ts +++ b/scripts/parse-log.ts | |||
@@ -17,6 +17,8 @@ program | |||
17 | .option('-f, --files [file...]', 'Files to parse. If not provided, the script will parse the latest log file from config)') | 17 | .option('-f, --files [file...]', 'Files to parse. If not provided, the script will parse the latest log file from config)') |
18 | .parse(process.argv) | 18 | .parse(process.argv) |
19 | 19 | ||
20 | const options = program.opts() | ||
21 | |||
20 | const excludedKeys = { | 22 | const excludedKeys = { |
21 | level: true, | 23 | level: true, |
22 | message: true, | 24 | message: true, |
@@ -38,7 +40,7 @@ const loggerFormat = winston.format.printf((info) => { | |||
38 | if (CONFIG.LOG.PRETTIFY_SQL) { | 40 | if (CONFIG.LOG.PRETTIFY_SQL) { |
39 | additionalInfos += '\n' + sqlFormat(info.sql, { | 41 | additionalInfos += '\n' + sqlFormat(info.sql, { |
40 | language: 'sql', | 42 | language: 'sql', |
41 | ident: ' ' | 43 | indent: ' ' |
42 | }) | 44 | }) |
43 | } else { | 45 | } else { |
44 | additionalInfos += ' - ' + info.sql | 46 | additionalInfos += ' - ' + info.sql |
@@ -51,7 +53,7 @@ const loggerFormat = winston.format.printf((info) => { | |||
51 | const logger = winston.createLogger({ | 53 | const logger = winston.createLogger({ |
52 | transports: [ | 54 | transports: [ |
53 | new winston.transports.Console({ | 55 | new winston.transports.Console({ |
54 | level: program['level'] || 'debug', | 56 | level: options.level || 'debug', |
55 | stderrLevels: [], | 57 | stderrLevels: [], |
56 | format: winston.format.combine( | 58 | format: winston.format.combine( |
57 | winston.format.splat(), | 59 | winston.format.splat(), |
@@ -76,7 +78,7 @@ run() | |||
76 | .catch(err => console.error(err)) | 78 | .catch(err => console.error(err)) |
77 | 79 | ||
78 | function run () { | 80 | function run () { |
79 | return new Promise(async res => { | 81 | return new Promise<void>(async res => { |
80 | const files = await getFiles() | 82 | const files = await getFiles() |
81 | 83 | ||
82 | for (const file of files) { | 84 | for (const file of files) { |
@@ -114,7 +116,7 @@ async function getNewestFile (files: string[], basePath: string) { | |||
114 | } | 116 | } |
115 | 117 | ||
116 | async function getFiles () { | 118 | async function getFiles () { |
117 | if (program['files']) return program['files'] | 119 | if (options.files) return options.files |
118 | 120 | ||
119 | const logFiles = await readdir(CONFIG.STORAGE.LOG_DIR) | 121 | const logFiles = await readdir(CONFIG.STORAGE.LOG_DIR) |
120 | 122 | ||
diff --git a/scripts/plugin/install.ts b/scripts/plugin/install.ts index 54738f50f..2ea8a658b 100755 --- a/scripts/plugin/install.ts +++ b/scripts/plugin/install.ts | |||
@@ -12,12 +12,14 @@ program | |||
12 | .option('-p, --plugin-path [pluginPath]', 'Path of the plugin you want to install') | 12 | .option('-p, --plugin-path [pluginPath]', 'Path of the plugin you want to install') |
13 | .parse(process.argv) | 13 | .parse(process.argv) |
14 | 14 | ||
15 | if (!program['npmName'] && !program['pluginPath']) { | 15 | const options = program.opts() |
16 | |||
17 | if (!options.npmName && !options.pluginPath) { | ||
16 | console.error('You need to specify a plugin name with the desired version, or a plugin path.') | 18 | console.error('You need to specify a plugin name with the desired version, or a plugin path.') |
17 | process.exit(-1) | 19 | process.exit(-1) |
18 | } | 20 | } |
19 | 21 | ||
20 | if (program['pluginPath'] && !isAbsolute(program['pluginPath'])) { | 22 | if (options.pluginPath && !isAbsolute(options.pluginPath)) { |
21 | console.error('Plugin path should be absolute.') | 23 | console.error('Plugin path should be absolute.') |
22 | process.exit(-1) | 24 | process.exit(-1) |
23 | } | 25 | } |
@@ -32,6 +34,6 @@ run() | |||
32 | async function run () { | 34 | async function run () { |
33 | await initDatabaseModels(true) | 35 | await initDatabaseModels(true) |
34 | 36 | ||
35 | const toInstall = program['npmName'] || program['pluginPath'] | 37 | const toInstall = options.npmName || options.pluginPath |
36 | await PluginManager.Instance.install(toInstall, program['pluginVersion'], !!program['pluginPath']) | 38 | await PluginManager.Instance.install(toInstall, options.pluginVersion, !!options.pluginPath) |
37 | } | 39 | } |
diff --git a/scripts/plugin/uninstall.ts b/scripts/plugin/uninstall.ts index c56f18466..8710b1750 100755 --- a/scripts/plugin/uninstall.ts +++ b/scripts/plugin/uninstall.ts | |||
@@ -9,7 +9,9 @@ program | |||
9 | .option('-n, --npm-name [npmName]', 'Package name to install') | 9 | .option('-n, --npm-name [npmName]', 'Package name to install') |
10 | .parse(process.argv) | 10 | .parse(process.argv) |
11 | 11 | ||
12 | if (!program['npmName']) { | 12 | const options = program.opts() |
13 | |||
14 | if (!options.npmName) { | ||
13 | console.error('You need to specify the plugin name.') | 15 | console.error('You need to specify the plugin name.') |
14 | process.exit(-1) | 16 | process.exit(-1) |
15 | } | 17 | } |
@@ -25,6 +27,6 @@ async function run () { | |||
25 | 27 | ||
26 | await initDatabaseModels(true) | 28 | await initDatabaseModels(true) |
27 | 29 | ||
28 | const toUninstall = program['npmName'] | 30 | const toUninstall = options.npmName |
29 | await PluginManager.Instance.uninstall(toUninstall) | 31 | await PluginManager.Instance.uninstall(toUninstall) |
30 | } | 32 | } |
diff --git a/scripts/reset-password.ts b/scripts/reset-password.ts index 6372095d6..7e7de6b8a 100755 --- a/scripts/reset-password.ts +++ b/scripts/reset-password.ts | |||
@@ -10,14 +10,16 @@ program | |||
10 | .option('-u, --user [user]', 'User') | 10 | .option('-u, --user [user]', 'User') |
11 | .parse(process.argv) | 11 | .parse(process.argv) |
12 | 12 | ||
13 | if (program['user'] === undefined) { | 13 | const options = program.opts() |
14 | |||
15 | if (options.user === undefined) { | ||
14 | console.error('All parameters are mandatory.') | 16 | console.error('All parameters are mandatory.') |
15 | process.exit(-1) | 17 | process.exit(-1) |
16 | } | 18 | } |
17 | 19 | ||
18 | initDatabaseModels(true) | 20 | initDatabaseModels(true) |
19 | .then(() => { | 21 | .then(() => { |
20 | return UserModel.loadByUsername(program['user']) | 22 | return UserModel.loadByUsername(options.user) |
21 | }) | 23 | }) |
22 | .then(user => { | 24 | .then(user => { |
23 | if (!user) { | 25 | if (!user) { |
@@ -28,7 +30,7 @@ initDatabaseModels(true) | |||
28 | const readline = require('readline') | 30 | const readline = require('readline') |
29 | const Writable = require('stream').Writable | 31 | const Writable = require('stream').Writable |
30 | const mutableStdout = new Writable({ | 32 | const mutableStdout = new Writable({ |
31 | write: function (chunk, encoding, callback) { | 33 | write: function (_chunk, _encoding, callback) { |
32 | callback() | 34 | callback() |
33 | } | 35 | } |
34 | }) | 36 | }) |