blob: 9b2139507d5cba0e73843e5a16a2816e65a58180 (
plain)
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
|
#!/usr/bin/env node
// Let this forever be of use to people who run into
// maxlistenersexceededwarning.
process.on('warning', e => console.warn(e.stack))
const { getCrawlerByName } = require('./crawlers')
async function main(args) {
let script
if (args.length === 0) {
console.error("No command provided.")
console.error("Try 'man http-music'?")
return
}
const module = getCrawlerByName(args[0])
if (module) {
script = module.main
} else {
switch (args[0]) {
case 'play': script = require('./play'); break
case 'download-playlist': script = require('./download-playlist'); break
case 'smart-playlist': script = require('./smart-playlist'); break
default:
console.error(`Invalid command "${args[0]}" provided.`)
console.error("Try 'man http-music'?")
return
}
}
await script(args.slice(1))
}
module.exports = main
if (require.main === module) {
main(process.argv.slice(2))
.catch(err => console.error(err))
}
|