musicmetadata
Advanced tools
Comparing version 0.6.6 to 1.0.0
{ | ||
"name": "musicmetadata", | ||
"version": "0.6.1", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/leetreveil/node-musicmetadata", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -9,4 +9,4 @@ 'use strict'; | ||
module.exports = function (stream, opts) { | ||
return musicmetadata(wrapFileWithStream(stream), opts) | ||
module.exports = function (stream, opts, callback) { | ||
return musicmetadata(wrapFileWithStream(stream), opts, callback) | ||
} | ||
@@ -13,0 +13,0 @@ |
@@ -8,4 +8,8 @@ 'use strict'; | ||
var MusicMetadata = module.exports = function (stream, opts) { | ||
opts = opts || {}; | ||
var MusicMetadata = module.exports = function (stream, opts, callback) { | ||
if (typeof opts === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
var emitter = new events.EventEmitter(); | ||
@@ -105,9 +109,3 @@ | ||
// don't emit the metadata event if nothing | ||
// ever gets added to the metadata object | ||
if (Object.keys(aliased).length > 0) { | ||
emitter.emit('metadata', metadata); | ||
} | ||
emitter.emit('done', exception); | ||
callback(exception, metadata) | ||
return strtok.DONE; | ||
@@ -114,0 +112,0 @@ } |
{ | ||
"name": "musicmetadata", | ||
"description": "Streaming music metadata parser for node and the browser.", | ||
"version": "0.6.6", | ||
"version": "1.0.0", | ||
"author": "Lee Treveil", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
@@ -37,7 +37,5 @@ [![Build Status][travis-image]][travis-url] [![NPM version][npm-image]][npm-url] [![npm downloads][npm-downloads-image]][npm-url] | ||
// create a new parser from a node ReadStream | ||
var parser = mm(fs.createReadStream('sample.mp3')); | ||
// listen for the metadata event | ||
parser.on('metadata', function (result) { | ||
console.log(result); | ||
var parser = mm(fs.createReadStream('sample.mp3'), function (err, metadata) { | ||
if (err) throw err; | ||
console.log(metadata); | ||
}); | ||
@@ -62,13 +60,5 @@ ``` | ||
If you just want the artist - listen for the artist event: | ||
`musicmetadata` also emits all metadata it discovers during parsing. For example if you wanted to read the `TLEN` frame from an id3v2.x file you can do this: | ||
```javascript | ||
parser.on('artist', function (result) { | ||
console.log(result); | ||
}); | ||
``` | ||
You can also listen for custom metadata types that are not part of the standard metadata as defined above. For example if you wanted to read the `TLEN` frame from a id3v2.x file you can do this: | ||
```javascript | ||
parser.on('TLEN', function (result) { | ||
@@ -79,20 +69,15 @@ console.log(result); | ||
The ```done``` event will be raised when parsing has finished or an error has occurred. This could be | ||
used to disconnect from the stream as soon as parsing has finished, saving bandwidth. | ||
You can also read the duration; to calculate the duration `musicmetadata` may need to parse the entire file | ||
so only enable this if you need the functionality. | ||
```javascript | ||
parser.on('done', function (err) { | ||
if (err) throw err; | ||
stream.destroy(); | ||
var parser = mm(fs.createReadStream('sample.mp3'), { duration: true }, function (err, metadata) { | ||
}); | ||
``` | ||
You can also read the duration; reading the duration may be slow so only set this if you need to. | ||
```javascript | ||
var parser = mm(fs.createReadStream('sample.mp3'), { duration: true }); | ||
``` | ||
Note that in order to read the duration for streams that are not file streams, you must also pass the size of the file in bytes. | ||
```javascript | ||
var parser = mm(fs.createReadStream('sample.mp3'), { duration: true, fileSize: 26838 }); | ||
var parser = mm(fs.createReadStream('sample.mp3'), { duration: true, fileSize: 26838 }, function (err, metadata) { | ||
}); | ||
``` | ||
@@ -105,3 +90,3 @@ | ||
Copyright (c) 2014 Lee Treveil <leetreveil@gmail.com> | ||
Copyright (c) 2015 Lee Treveil <leetreveil@gmail.com> | ||
@@ -108,0 +93,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
606837
12575
1
101