-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcoverInfo.js
51 lines (38 loc) · 1.08 KB
/
coverInfo.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
var fs = require('fs');
var path = require('path');
var dir = "public/img/";
function getFiles(dir, files_) {
files_ = files_ || [];
if (typeof files_ === 'undefined') files_ = [];
var files = fs.readdirSync(dir);
for (var i in files) {
if (!files.hasOwnProperty(i)) continue;
var name = 'img/' + files[i];
files_.push(name);
/*
if (fs.statSync(name).isDirectory()){
getFiles(name,files_);
} else {
files_.push(name);
}
*/
}
return files_;
}
var allcovers = getFiles(dir);
function outputNames() {
var artist = new Array(allcovers.length)
var album = new Array(allcovers.length)
for (var i = 0; i < allcovers.length; i++) {
var split = path.basename(allcovers[i]);
split = split.split(' - ');
if (split[1] !== undefined) {
artist[i] = split[0];
album[i] = split[1].split(path.extname(split[1]))[0];
}
}
return [album, artist];
}
var AlbumInfo = outputNames();
exports.AlbumInfo = AlbumInfo;
exports.allcovers = allcovers;