badger-am/lib/audio.js
2017-03-24 22:11:22 +01:00

15 lines
No EOL
446 B
JavaScript

// requirements
const fs = require('fs');
const metadata = require('musicmetadata');
// extract metadata for further processing
exports.extractMetadata = function extractMetadata(sourceFile, callback) {
const stream = fs.createReadStream(sourceFile);
metadata(stream, function (err, metadata) {
if (err) {
return callback(err);
}
stream.close();
callback(null, sourceFile, metadata)
});
};