15 lines
No EOL
446 B
JavaScript
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)
|
|
});
|
|
}; |