Guest User

Untitled

a guest
Oct 30th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const mm = require("music-metadata");
  2. const fs = require("fs");
  3. const path = require("path");
  4.  
  5. class meta {
  6.    
  7.     constructor(files) {
  8.         if(!files) throw Error("files not specified");
  9.         this.data = {};
  10.         this.ls = files;
  11.     }
  12.  
  13.   buildMeta() {
  14.      
  15.         var that = this;
  16.         return new Promise(function(resolve, reject) {
  17.         for(let i = 0; i < that.ls.length; i++) {
  18.        
  19.             mm.parseFile(that.ls[i]).then(x => {
  20.                 var info = x.common;
  21.                 that.data[info.artist] = "test";
  22.             }).catch((x) => {
  23.               reject(x);  
  24.             });
  25.        }
  26.        resolve(that.data);
  27.     });
  28.  
  29.      
  30.     }
  31. }
  32. module.exports = meta;
Add Comment
Please, Sign In to add comment