-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.js
executable file
·47 lines (36 loc) · 1.32 KB
/
index.js
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
#!/usr/bin/env node
var PrerequisitesChecker = require('./lib/prerequisites_checker');
PrerequisitesChecker(function() {
const _ = require('lodash');
const cli = require('cli');
const colors = require('colors');
const updateNotifier = require('update-notifier');
const { name, version } = require('./package.json');
const Saavn = require('./lib/providers/saavn');
const Gaana = require('./lib/providers/gaana');
const supportedProviders = [Saavn, Gaana];
updateNotifier({
pkg: { name, version },
updateCheckInterval: 1000 * 60 * 60 * 24 * 1 // Every day
}).notify();
cli.enable('version');
cli.setApp(name, version);
cli.parse();
if (!cli.args[0]) {
cli.error("Please provide the URL to the album/playlist of songs which you want to download.")
console.log("Usage:".bold);
console.log(" ", name, "URL_OF_ALBUM_OR_PLAYLIST_HERE".dim);
console.log();
console.log("For other options, use --help option.");
return;
}
const tracklistUrl = cli.args.shift();
const matchedProvider = _.find(supportedProviders, providerKlass => {
return (new providerKlass(tracklistUrl)).canIdentify();
});
if (matchedProvider) {
(new matchedProvider(tracklistUrl)).downloadTracks();
} else {
cli.error(`Couldn't identify the provided playlist/album URL: "${tracklistUrl}"`);
}
});