Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

taglib

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

taglib

Simple bindings to TagLib

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
1
Weekly downloads
 
Created
Source

node-taglib

node-taglib is a simple binding to TagLib in Javascript.

It requires node.js.

For now it exposes Tag and AudioProperties. Synchronous write support is supported for Tag.

NOTE: Asynchronous API requires use of TagLib from git since certain bugs present in the released v1.7 cause problems.

Example

// load the library
var taglib = require('taglib');

// asynchronous API
taglib.tag(path, function(err, tag) {
    tag.artist; // => "Queen"
    tag.title = "Erm";
    tag.saveSync();
});

// synchronous API
var tag = taglib.tagSync(path);

tag.title; // => "Another one bites the dust"
tag.artist; // => "Kween"
tag.artist = "Queen";

tag.isEmpty(); // => false

tag.saveSync(); // => true

Installation

npm install taglib

From source

# make sure you have node and taglib installed
git clone git://github.com/nikhilm/node-taglib.git
cd node-taglib
node-waf configure build
node examples/simple.js /path/to/mp3_or_ogg_file
# you can now require('./taglib')

The examples show usage.

API

tag(path, callback)

Read the tag from the file at path asynchronously. The callback should have signature (err, tag). On success, err will be null and tag will be a Tag. If errors occurred, err will contain the error and tag will be null. err will be an object with field code having the integer error code (errno.h) and field message will have a string representation.

tagSync(path)

Read the tag from the file at path synchronously. Returns a Tag. If errors occurred, throws an exception.

Tag

NOTE: A Tag object should NOT be created using new. Instead use tag() or tagSync()

A Tag object allows access to all the meta-data fields. node-taglib currently supports only the fields common to all formats:

  • title (string)
  • album (string)
  • comment (string)
  • artist (string)
  • track (string)
  • year (integer)
  • genre (string)

To get a value, simply access the field -- tag.artist.

To set a value, assign a value to the field -- tag.year = 2012. You will have to call saveSync() to actually save the changes to the file on disc.

Large number of files

Due to TagLib's design, every Tag object in memory has to keep its backing file descriptor open. If you are dealing with a large number of files, you will soon run into problems because operating systems impose limits on how many files a process can have open simultaneously. If you only want to read meta-data and not write it immediately, then deep copy the fields over to a plain JS object, then dispose the Tag object so that you can operate on more files.

Tag.save(callback)

Save any changes in the Tag meta-data to disk asynchronously. callback will be invoked once the save is done, and should have a signature (err). err will be null if the save was successful, otherwise it will be an object with message having the error string and path having the file path.

Tag.saveSync()

Save any changes in the Tag meta-data to disk synchronously.

Tag.isEmpty()

Returns whether the tag is empty or not.

AudioProperties(path)

NOTE: This will be replaced by a more functional API, similar to the tags API.

Object to get the audio properties of file at path. Throws an exception on errors.

var ap = new taglib.AudioProperties('path');
console.log("Bitrate", ap.bitrate);

The following fields are available:

  • length
  • bitrate
  • sampleRate
  • channels

Writing audio properties is not supported.

taglib.WITH_ASF

A boolean representing whether node-taglib supports ASF files. Depends on feature being enabled in TagLib.

taglib.WITH_MP4

A boolean representing whether node-taglib supports MP4 files. Depends on feature being enabled in TagLib.

Contributors are listed at: https://github.com/nikhilm/node-taglib/contributors

FAQs

Package last updated on 22 Mar 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc