forked from qrpike/spotify-playlist-downloader
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.js
70 lines (45 loc) · 1.92 KB
/
main.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env node
// Generated by CoffeeScript 1.10.0
(function() {
var DIRECTORY, Downloader, FOLDER, GENERATE, PASSWORD, PLAYLIST, Program, USERNAME, getUserHome;
require('coffee-script');
require('colors');
Program = require('commander');
Downloader = require('./lib/downloader');
getUserHome = (function(_this) {
return function() {
if (process.platform === 'win32') {
return process.env['USERPROFILE'];
}
return process.env['HOME'];
};
})(this);
Program.version('0.1.0').option('-u, --username [username]', 'Spotify Username (required)', null).option('-p, --password [password]', 'Spotify Password (required)', null).option('-l, --link [link/uri]', 'Spotify URI for playlist, album or track', null).option('-d, --directory [directory]', "Directory you want to save the mp3s to, default: " + (getUserHome()) + "/spotify-mp3s", (getUserHome()) + "/spotify-mp3s").option('-f, --folder', "create folder for playlist", null).option('-g, --generate', "generate file for playlist", null).parse(process.argv);
USERNAME = Program.username;
PASSWORD = Program.password;
PLAYLIST = Program.link;
DIRECTORY = Program.directory;
FOLDER = Program.folder;
GENERATE = Program.generate;
if ((PASSWORD == null) || (USERNAME == null)) {
console.log('!!! MUST SPECIFY USERNAME & PASSWORD !!!'.red);
return Program.outputHelp();
}
if (PLAYLIST == null) {
console.log('!!! MUST SPECIFY A SPOTIFY PLAYLIST !!!'.red);
return Program.outputHelp();
}
console.log('init');
Downloader = new Downloader(USERNAME, PASSWORD, PLAYLIST, DIRECTORY);
Downloader.setPlaylist(PLAYLIST);
Downloader.setBasePath(DIRECTORY);
Downloader.setMakeFolder(FOLDER != null ? FOLDER : {
"true": false
});
Downloader.setGeneratePlaylist(GENERATE != null ? GENERATE : {
"true": false
});
console.log('run');
Downloader.run();
}).call(this);
//# sourceMappingURL=main.js.map