badger-am/lib/audio.js

15 lines
446 B
JavaScript
Raw Normal View History

2017-03-24 22:05:51 +01:00
// requirements
2017-03-24 22:11:22 +01:00
const fs = require('fs');
2017-03-24 22:05:51 +01:00
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)
});
};