diff options
author | liam4 <towerofnix@gmail.com> | 2017-08-01 11:33:19 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-08-01 11:33:19 -0300 |
commit | 6f4ce94467db4e95cab117007e3724695b7d9533 (patch) | |
tree | c327223c9e8ad031ae31ccdca97141123e531ecd /src/cli.js | |
parent | e02f90272a805f85f94adec8d790eaf45dcf9c3f (diff) |
Smart playlists
Diffstat (limited to 'src/cli.js')
-rwxr-xr-x | src/cli.js | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/cli.js b/src/cli.js index 4bc64ab..9b21395 100755 --- a/src/cli.js +++ b/src/cli.js @@ -4,6 +4,8 @@ // maxlistenersexceededwarning. process.on('warning', e => console.warn(e.stack)) +const { getCrawlerByName } = require('./crawlers') + async function main(args) { let script @@ -13,18 +15,21 @@ async function main(args) { return } - switch (args[0]) { - case 'play': script = require('./play'); break - case 'crawl-http': script = require('./crawl-http'); break - case 'crawl-local': script = require('./crawl-local'); break - case 'crawl-itunes': script = require('./crawl-itunes'); break - case 'crawl-youtube': script = require('./crawl-youtube'); break - case 'download-playlist': script = require('./download-playlist'); break - - default: - console.error(`Invalid command "${args[0]}" 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)) |