music-tag
v0.0.9
Published
ID3 reader and writer for NodeJS
Downloads
5
Readme
music-tag
ID3 reader and writer for NodeJS
Usage
id3.read(path, [opts])
The read
method returns a promise for a ReadResult
or an array of ReadResult
of the path requested. The path
parameter is a
String with the path (relative or absolute) of a file or folder. The optional opts
parameter is an object with the
following properties:
recursive
: Read recursively when the path parameter is a folder path. ( Boolean. Default: true )each
: A function to be called for each result ( Function (ReadResult). Default: null )
For example:
var id3 = require('music-tag');
id3.read('music.mp3').then(function(result) {
console.log(result.data);
}).fail(function(err) {
throw err;
});
id3.write(path, tags, [opts])
The write
method returns a promise for a WriteResult
or an array of WriteResult
of the path requested. The path
parameter
is a String with the path (relative or absolute) of a file or folder. The tags
parameter is an object with the new
tags to add to the path. The optional opts
parameter is an object with the following properties:
recursive
: Write recursively when the path parameter is a folder path. ( Boolean. Default: true )each
: A function to be called for each result ( Function (WriteResult). Default: null )replace
: Removes any previously existing tag. ( Boolean. Default: false )
For example:
var id3 = require('music-tag');
id3.write('music.mp3', { artist: 'Me' }).then(function(result) {
console.log(result.tags);
}).fail(function(err) {
throw err;
});
ReadResult
The ReadResult
object contains the following properties:
path
: Path of the read file ( String )tags
: The tags read ( Object )
WriteResult
The WriteResult
object contains the following properties:
path
: Path of the written file ( String )tags
: The tags written ( Object )
Development
Run the following command to install the development dependencies:
npm install
The project uses Gulp as build system. Run the following command to install gulp:
npm install -g gulp
The dev
task provides a loop that runs JSHint and Mocha when a change is detected. Run the following command to start the task:
gulp dev