Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var walk = function(dir, done) {
- var results = []
- fs.readdir(dir, function(err, list) {
- var artist = [];
- list.forEach(function(item, callback) {
- artist.push({artist: item});
- if(err) return done(err);
- var i = 0;
- (function next() {
- var tmp = [];
- var file = list[i++]
- if(!file) return done(null, results);
- fulldir = dir + '/' + file;
- fs.stat(fulldir, function(err, stat) {
- if(stat && stat.isDirectory()) {
- walk(fulldir, function(err, res) {
- artist.push({album: file});
- //artist[file] = res;
- //results.push(artist);
- //tmp.push(file);
- //tmp.push(res)
- // results.push({artist: file});
- // results.push(res);
- next();
- });
- }
- else {
- if(path.extname(file) =='.mp3')
- //tmp.push(file);
- next();
- }
- });
- })();
- });
- results.push(artist);
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement