-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathconfig.ts
60 lines (55 loc) · 1.51 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import nconf from 'nconf'
import fs from 'fs'
import xml2js from 'xml2js'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg = require('../package.json')
const defaults = {
caspar: {
config: './casparcg.config',
},
paths: {
template: './template',
media: './media',
font: './font',
ffmpeg: process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg',
ffprobe: process.platform === 'win32' ? 'ffprobe.exe' : 'ffprobe',
},
scanner: {
paths: null,
// Note: See https://www.npmjs.com/package/chokidar#api.
},
thumbnails: {
width: 256,
height: -1,
},
metadata: {
fieldOrder: false, // This is an expensive check, as it requires decoding the beginning of the video
fieldOrderScanDuration: 200, // Frames. Note: Needs sufficient motion (Not titlecard)
},
isProduction: process.env.NODE_ENV === 'production',
logger: {
level: process.env.NODE_ENV === 'production' ? 'info' : 'trace',
name: pkg.name,
print: process.env.NODE_ENV !== 'production',
},
http: {
port: 8000,
host: undefined,
},
}
export const config = nconf.argv().env('__').defaults(defaults).get()
if (config.caspar && config.caspar.config) {
const parser = new xml2js.Parser()
const data = fs.readFileSync(config.caspar.config)
parser.parseString(data, (err, result) => {
if (err) {
throw err
}
for (const path in result.configuration.paths[0]) {
config.paths[path.split('-')[0]] = result.configuration.paths[0][path][0]
}
})
}
if (!config.scanner.path) {
config.scanner.paths = config.paths.media
}