• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 15 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple taglib bindings to Javascript using node.js

node-taglib

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

It requires node.js and taglib header files (on Debian systems, install libtag1-dev).

node-taglib offers only an abstract interface without giving access to extended file-specific attributes. It does allow custom resolvers though. 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

via npm (Recommended)

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
npm install .
node examples/simple.js /path/to/mp3_or_ogg_file
# you can now require('./taglib')

The examples show usage.

API

read(path, callback)

read(buffer, format, callback)

The function you will most likely want to use. callback should have signature callback(err, tag, audioProperties) where tag and audioProperties are plain-old JavaScript objects. For the distinction between these and Tag, see Tag below.

If there was an error reading the file, err will be non-null and tag and audioProperties will be null.

If no tag was found, tag will be an empty object (falsy). tag can have the following 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)

If no audio properties could be read, audioProperties will be an empty object (falsy). The following fields are available in audioProperties, all are integers:

  • length
  • bitrate
  • sampleRate
  • channels

Writing audio properties is not supported.

In the second variant, which can read from a buffer, format should be a string as specified in Formats.

tag(path, callback)

tag(buffer, format, 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.

In the second variant, which can read from a buffer, format should be a string as specified in Formats.

tagSync(path)

tagSync(buffer, format)

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

Read the tags from buffer assuming that it is a format file. See Formats

Tag

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

A Tag object allows read-write access to all the meta-data fields. For valid field names see read() above.

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 want to only read tags, use read() instead as it will immediately close the file after the tag is read.

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. Throws an exception if the save failed.

Tag.isEmpty()

Returns whether the tag is empty or not.

taglib.addResolvers([resolver1[, resolver2[, ...]]])

Adds JavaScript functions that will be called to resolve the filetype of a file. Each resolver will be added to the front of the resolver queue. So the last resolver will be called first. Multiple calls to addResolvers are allowed.

Each resolver must be a JavaScript function which takes a filename parameter and returns a format string. List of formats.

Formats {#formats}

Any place where node-taglib expects a format can be passed one of these (case-insensitive):

"MPEG"
"OGG"      - Ogg Vorbis
"OGG/FLAC" - Ogg FLAC
"FLAC"
"MPC"
"WV"
"SPX"      - Ogg Speex
"TTA"
"MP4"
"ASF"
"AIFF"     - RIFF AIFF
"WAV"      - RIFF WAV
"APE"
"MOD"
"S3M"
"IT"
"XM"

These correspond directly to the filetypes supported by TagLib. If the filetype cannot be determined, return anything other than one of these literals.

Asynchronous resolvers (which indicate the filetype via a callback rather than a return value) are 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

More Repositories

1

uvbook

An Introduction to libuv
C
1,588
star
2

qhttpserver

HTTP server implementation for Qt based on node.js' http parser
C
343
star
3

kademlia

DHT implementation
JavaScript
142
star
4

gocco

Go port of Jash Kenas' docco
Go
67
star
5

ninja-rs

An educational implementation of the ninja build system, based on ideas from the Build Systems a la Carte paper.
Rust
56
star
6

jsfoo-pune-2012

Native Bindings to node.js - Slides and code for the talk at jsfoo
C++
33
star
7

flickr-hugo-embed

Print shortcodes to embed a set of images from an album on Flickr into Hugo
JavaScript
23
star
8

vignette

A sampling profiler as a library
Rust
13
star
9

tictactoe

zero server-side logic 2-player realtime tic-tac-toe.
JavaScript
12
star
10

sasljs

Server side SASL support for node.js
C++
12
star
11

rustc-worker

A Bazel persistent worker for Rust
Rust
8
star
12

qommunicate

[old-project] A Qt-based cross-platform implementation of the IPmsg (http://ipmsg.org) protocol
C++
8
star
13

mugshot

Simple face detection web service
JavaScript
7
star
14

simplechat

SimplePush based chat.
JavaScript
5
star
15

kio-upnp-ms

Mirror of http://gitorious.org/kio-upnp-ms
C++
4
star
16

socket-ipc

Benchmarking unix domain sockets vs UDP multicast performance
C++
2
star
17

container-experiments

Playing with Linux containerization primitives
Rust
2
star
18

upnpls

Browse UPnP MediaServers using Qt and HUPnP
C++
2
star
19

minestrone

Meant to be a music streaming server based on node.js
JavaScript
2
star
20

solarwolf-qml

A port of Solarwolf (http://www.pygame.org/shredwheat/solarwolf/) to QML
JavaScript
2
star
21

logos

[DEAD] A XMPP server powered by node.js, currently in embryonic stage
JavaScript
2
star
22

Tetrablocks

[old-project] Because everyone has to implement tetris atleast once in their lives. C++ and SDL
C++
2
star
23

confkdein11

Code for KDE India Conference talks (March 9th-11th)
JavaScript
2
star
24

python-struct-unpacking

some experiments with struct.unpack performance
Python
2
star
25

save-my-tabs

Save Chrome tabs (to Dropbox for now)
JavaScript
1
star
26

unwind-arguments

Example code for a blog post.
C
1
star
27

substrate.js

Submission for the js1k contest
JavaScript
1
star
28

api-test

test repository for github API experiments
1
star
29

compilers-assignment

C
1
star
30

brainstorm

Something like a whiteboard Development is now at BitBucket http://bitbucket.org/nikhilm/brainstorm/
Java
1
star
31

login

[old-project] Conway's game of life in SDL
C++
1
star
32

valdo

Todo system based on backbone.js and OpenKeyVal.org
JavaScript
1
star
33

rational

Rational human-readable argument parser for node.js
JavaScript
1
star
34

AdventOfCode2020

Solutions in Pharo Smalltalk
Smalltalk
1
star
35

cleanup

A Javascript (Canvas) clone of Solarwolf for the CodeChef May 2009 game contest
JavaScript
1
star
36

pypes

[old-project] Pygame based clone of mobile game. Connect all the pipes together into a coherent whole.
Python
1
star
37

muzicast

web based music streaming server [software engineering project]
Python
1
star
38

threadtimes

benchmarking time to retrieve thread usage times on various operating systems
Rust
1
star
39

lunchbot

A easy way to coordinate lunch on IRC
JavaScript
1
star
40

squeeze

node.js library to interact with UploadJuicer.com's cloud image manipulation service
JavaScript
1
star
41

foss.in

Twitter client from the KDE PotD
C++
1
star
42

push-app-to-phone

SimplePush uber-demo
JavaScript
1
star
43

preserve

Python implementation of the esoteric Chef programming language. A spontaneous top-of-my-head effort.
Python
1
star
44

unbound

A prototype collaborative textbook web application created at a MIT Media Lab workshop in 2 days.
JavaScript
1
star
45

pixelframe

[old-project] Pixelframe. Ajaxified, awesome (for that time) image gallery powered by PHP and custom JS library.
JavaScript
1
star
46

ricochet

[old-project] Use mirrors to guide the light to the switch and go to the next level. Python + Pygame
C++
1
star
47

muc

demo multi user chat with support for multiple rooms using node + NowJS
JavaScript
1
star