Advertisement
Guest User

Untitled

a guest
Aug 29th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var walk = function(dir, done) {
  2.     var results = []
  3.     fs.readdir(dir, function(err, list) {
  4.         var artist = [];
  5.         list.forEach(function(item, callback) {
  6.             artist.push({artist: item});
  7.  
  8.         if(err) return done(err);
  9.         var i = 0;
  10.         (function next() {
  11.             var tmp = [];
  12.             var file = list[i++]
  13.             if(!file) return done(null, results);
  14.             fulldir = dir + '/' + file;
  15.  
  16.             fs.stat(fulldir, function(err, stat) {
  17.                 if(stat && stat.isDirectory()) {
  18.  
  19.                     walk(fulldir, function(err, res) {
  20.                         artist.push({album: file});
  21.                         //artist[file] = res;
  22.                         //results.push(artist);
  23.                         //tmp.push(file);
  24.                         //tmp.push(res)
  25.                         // results.push({artist: file});
  26.                         // results.push(res);
  27.                         next();
  28.                     });
  29.  
  30.                 }
  31.                 else {
  32.                     if(path.extname(file) =='.mp3')
  33.                         //tmp.push(file);
  34.                     next();
  35.                 }
  36.             });
  37.  
  38.         })();
  39.             });
  40.  
  41.         results.push(artist);
  42.     });
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement