Git Product home page Git Product logo

node-taglib's Introduction

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

node-taglib's People

Contributors

dekz avatar emersion avatar josephmoniz avatar masterkain avatar nikhilm avatar orospakr avatar theopolisme avatar visakhsebastian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

node-taglib's Issues

suport for lyrics

Thanks for the great library.
When will youl support lyrics tags?

tks

The state of windows build

As I tried (for hours) to get the project built on windows, I just wanted to ask what the current state of porting it to work on windows is.

After I got taglib 1.8 to compile through MSVC (Express Version 2010), I struggled getting the binding compiled. Some things like sys/time.h need to be #ifdeffed for Windows to include just time.h, your "now()" function seems to be uneeded and doesn't compiled so this went out as well.

In the end there where some weird bugs, concerning "no appropriate default constructor available" on initialization of AsyncBaton.

Maybe I could open up a windows branch and document the errors in the whole…

Compilation was on Windows 7 32Bit as 64bit taglib didn't compile (some linker error)
Node 0.8.20 32bit, latest node-gyp

Let me know what you think.

best regards,

Lennart

Fail to build with nodejs 12.x on Arch Linux

Below is the output for the issue:

$ taglib-config --version
1.9.1
$ node --version         
v0.12.0
$ npm install            
npm WARN engine [email protected]: wanted: {"node":">=0.10.0 <0.11"} (current: {"node":"0.12.0","npm":"2.5.1"})
\
> [email protected] install /home/benkaiser/GIT/node-music-player/node_modules/taglib
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
make: Entering directory '/home/benkaiser/GIT/node-music-player/node_modules/taglib/build'
  CXX(target) Release/obj.target/taglib/src/bufferstream.o
In file included from ../src/bufferstream.cc:5:0:
../src/taglib.h:26:47: error: ‘Arguments’ in namespace ‘v8’ does not name a type
 v8::Handle<v8::Value> AsyncReadFile(const v8::Arguments &args);
                                               ^
../src/taglib.h:46:46: error: ‘Arguments’ in namespace ‘v8’ does not name a type
 v8::Handle<v8::Value> AddResolvers(const v8::Arguments &args);
                                              ^
taglib.target.mk:87: recipe for target 'Release/obj.target/taglib/src/bufferstream.o' failed
make: *** [Release/obj.target/taglib/src/bufferstream.o] Error 1
make: Leaving directory '/home/benkaiser/GIT/node-music-player/node_modules/taglib/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Linux 3.17.1-1-ARCH
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/benkaiser/GIT/node-music-player/node_modules/taglib
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 
npm ERR! Linux 3.17.1-1-ARCH
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the taglib package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls taglib
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/benkaiser/GIT/node-music-player/npm-debug.log

This may help with fixing the issue: https://github.com/mochajs/mocha/pull/1287/files

incorrect link when building master

  if not os.path.exists('lib/taglib_binding.node'):
      os.symlink( '../build/Release/taglib_binding.node', 'lib/taglib_binding.node')

When building the latest master I do not have build/Release but build/default, so the symbolic link will have a missing target and the app won't start.

Error: Cannot find module '/mypath/node_modules/taglib/lib/taglib_binding'

I edited the initial path name above.

[ruby-1.9.3-preview1] 00:08 ~/mypath/node_modules/taglib/lib (tests)$ ls -lha
total 16
drwxr-xr-x   4 kain  staff   136B 17 Ott 00:07 .
drwxr-xr-x  14 kain  staff   476B 17 Ott 00:07 ..
-rw-r--r--   1 kain  staff   317B 17 Ott 00:07 taglib.js
lrwxr-xr-x   1 kain  staff    36B 17 Ott 00:07 taglib_binding.node -> ../build/Release/taglib_binding.node

[ruby-1.9.3-preview1] 00:16 ~/mypath/node_modules/taglib/build/default (tests)$ ls -lha
total 192
drwxr-xr-x  4 kain  staff   136B 17 Ott 00:07 .
drwxr-xr-x  6 kain  staff   204B 17 Ott 00:07 ..
drwxr-xr-x  5 kain  staff   170B 17 Ott 00:07 src
-rwxr-xr-x  1 kain  staff    92K 17 Ott 00:07 taglib_binding.node

node-gyp rebuild failing

I'm running 0.10.4 Node.JS and node-gyp 0.9.5. When I run "npm install taglib" the build process fails with a bunch of output.

Do you need anything from me to help resolve this issue? The full terminal dump?

Problem building master, involving lib/taglib.node

[~/code/mine/phonograph/node_modules/taglib]$ npm install                                                                                                                                          [master] 

> [email protected] preinstall /home/orospakr/code/mine/phonograph/node_modules/taglib
> node-waf clean || true; node-waf configure build

'clean' finished successfully (0.000s)
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
Checking for taglib                      : yes 
'configure' finished successfully (0.055s)
Waf: Entering directory `/home/orospakr/code/mine/phonograph/node_modules/taglib/build'
[1/4] cxx: src/audioproperties.cc -> build/Release/src/audioproperties_1.o
[2/4] cxx: src/tag.cc -> build/Release/src/tag_1.o
[3/4] cxx: src/taglib.cc -> build/Release/src/taglib_1.o
[4/4] cxx_link: build/Release/src/audioproperties_1.o build/Release/src/tag_1.o build/Release/src/taglib_1.o -> build/Release/taglib.node
Waf: Leaving directory `/home/orospakr/code/mine/phonograph/node_modules/taglib/build'
Traceback (most recent call last):
  File "/usr/local/bin/node-waf", line 16, in <module>
    Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
    prepare_impl(t, cwd, ver, wafdir)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
    main()
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 188, in main
    fun(ctx)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 386, in build
    return build_impl(bld)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 411, in build_impl
    bld.post_build()
  File "/usr/local/bin/../lib/node/wafadmin/Build.py", line 1003, in post_build
    m(self)
  File "/home/orospakr/code/mine/phonograph/node_modules/taglib/wscript", line 22, in post_build
    os.symlink(os.path.join(base_path, 'taglib.node'), 'lib/taglib.node')
OSError: [Errno 2] No such file or directory
npm ERR! [email protected] preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the taglib package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf clean || true; node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls taglib
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Linux 3.0.0-12-generic
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/orospakr/code/mine/phonograph/node_modules/taglib
npm ERR! node -v v0.6.1
npm ERR! npm -v 1.0.105
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/orospakr/code/mine/phonograph/node_modules/taglib/npm-debug.log
npm not ok

Coverart / image support

Thanks for the great library. I am currently writing a review of various nodejs id3 tag libraries and yours is the best performance-wise. However there is one critical feature missing, coverart support. Is this planned to be implemented? it appears it is part of the taglib functionality for mp3s at least

Simplify API and fix a few issues

I've pushed a new README.md to branch 'memtag', which describes how the new API would be.

The Metadata object is actually a standard JS object with none of the accessor code that is currently in use for the Tag object. It has write() and writeSync() methods which will handle copying back values from v8 to taglib.

This simplifies the API drastically - no read() vs. tag(), no 'audio-properties are second class'. There is also a big reduction in the number of lines of code under the hood.

The changes will also fix parts of #38 which is that FileRefs will be closed as soon as data has been read, and then save() will reopen a fileref.
#35 will also be fixed with readSync() providing access to audio properties as well.

I have some WIP patches that make all these changes. @lennart @masterkain I would appreciate your thoughts on this. Thanks!

Unable to compile against Taglib's master

Taglib installed from '2c2a4863132c2c041df0b2adab471e0731f2dd26'.

'configure' finished successfully (0.032s)
Waf: Entering directory /home/emilsedgh/node_modules/taglib/build' [1/4] cxx: src/bufferstream.cc -> build/Release/src/bufferstream_1.o [2/4] cxx: src/tag.cc -> build/Release/src/tag_1.o [3/4] cxx: src/taglib.cc -> build/Release/src/taglib_1.o In file included from ../src/tag.cc:8:0: ../src/taglib.h:49:5: error: ‘uv_mutex_t’ does not name a type ../src/taglib.h:57:11: error: ‘uv_thread_t’ does not name a type In file included from ../src/bufferstream.cc:5:0: ../src/taglib.h:49:5: error: ‘uv_mutex_t’ does not name a type ../src/taglib.h:57:11: error: ‘uv_thread_t’ does not name a type In file included from ../src/taglib.cc:6:0: ../src/taglib.h:49:5: error: ‘uv_mutex_t’ does not name a type ../src/taglib.h:57:11: error: ‘uv_thread_t’ does not name a type ../src/taglib.cc: In constructor ‘node_taglib::CallbackResolver::CallbackResolver(v8::Persistent<v8::Function>)’: ../src/taglib.cc:305:7: error: class ‘node_taglib::CallbackResolver’ does not have any field named ‘created_in’ ../src/taglib.cc: In static member function ‘static void node_taglib::CallbackResolver::invokeResolverCb(uv_async_t*, int)’: ../src/taglib.cc:314:29: error: ‘struct node_taglib::AsyncResolverBaton’ has no member named ‘mutex’ ../src/taglib.cc:314:34: error: ‘uv_mutex_unlock’ was not declared in this scope ../src/taglib.cc: In member function ‘virtual TagLib::File* node_taglib::CallbackResolver::createFile(TagLib::FileName, bool, TagLib::AudioProperties::ReadStyle) const’: ../src/taglib.cc:341:9: error: ‘created_in’ was not declared in this scope ../src/taglib.cc:344:30: error: ‘struct node_taglib::AsyncResolverBaton’ has no member named ‘mutex’ ../src/taglib.cc:344:35: error: ‘uv_mutex_init’ was not declared in this scope ../src/taglib.cc:346:30: error: ‘struct node_taglib::AsyncResolverBaton’ has no member named ‘mutex’ ../src/taglib.cc:346:35: error: ‘uv_mutex_lock’ was not declared in this scope ../src/taglib.cc:348:30: error: ‘struct node_taglib::AsyncResolverBaton’ has no member named ‘mutex’ ../src/taglib.cc:359:9: error: ‘created_in’ was not declared in this scope ../src/taglib.cc:361:32: error: ‘struct node_taglib::AsyncResolverBaton’ has no member named ‘mutex’ ../src/taglib.cc:361:37: error: ‘uv_mutex_unlock’ was not declared in this scope ../src/taglib.cc:362:33: error: ‘struct node_taglib::AsyncResolverBaton’ has no member named ‘mutex’ ../src/taglib.cc:362:38: error: ‘uv_mutex_destroy’ was not declared in this scope Waf: Leaving directory/home/emilsedgh/node_modules/taglib/build'
Build failed:

Execution error?

I managed to install the node taglib however... its failing when I try to run it:

/app/noxindrive/node_modules/taglib/node_modules/bindings/bindings.js:79
throw e
^
Error: libtag.so.1: cannot open shared object file: No such file or directory
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at bindings (/app/noxindrive/node_modules/taglib/node_modules/bindings/bindings.js:74:15)
at Object. (/app/noxindrive/node_modules/taglib/examples/simple.js:1:95)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

I do have the libtag.so.1 so but probably the library is looking for it somewhere else?

TagLib 1.9 features

TagLib 1.9 introduces some new things like hookable API for debug messages, improved refcounting and some improvements in PropertyMap. See whether this can be exposed via node-taglib. Especially see if the too many open files issue can be resolved.

Useful Exceptions or Handling of missing m4a/wma Support

As pointed out in the README Exception Management is rather wonky in node-taglib. If the installed taglib lacks m4a support node-taglib just fails hard on reading such a file, throwing a generic "cannot read from this file error". I'll investigate solutions for handling such situations.

For those who want m4a support (and wma) rebuild your taglib from source with

cmake -DWITH_MP4=ON -DWITH_ASF=ON && make

and then install it again

Add async API

FileRef is blocking until the file is read, move this into the libuv thread pool.
Provide async and sync APIs.

Genre List

It seems like the genre field is incorrectly mapped to a String. That is, if I use the id3tool and set the genre of a file to Rock and then read it with this taglib binding, I get Blues as the genre.

It may be it's originating from the taglib itself, but I'm not sure how to check that. Any guesses?

Unify tag literal behaviour

whereas a empty Tag has fields which are null, an object acquired from read(), is empty when tags are empty (FileRef::tag() is null). Agree on one of these.

Artwork support

To be added to the wishlist.
Do you plan to do the bindings around artworks?
Keep up the good work. Looks very good. Cheers.

Installation error

OSXL 10.9.4
Installed 'taglib' with brew. 'taglib-1.9.1'

Error log:

$ npm install

> [email protected] install /Users/rolf/Documents/tools/node-music-player/node_modules/taglib
> node-gyp rebuild

  CXX(target) Release/obj.target/taglib/src/bufferstream.o
  CXX(target) Release/obj.target/taglib/src/tag.o
  CXX(target) Release/obj.target/taglib/src/taglib.o
  SOLINK_MODULE(target) Release/taglib.node
clang: error: invalid argument '-bundle' not allowed with '-dynamiclib'
make: *** [Release/taglib.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Darwin 13.3.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/rolf/Documents/tools/node-music-player/node_modules/taglib
gyp ERR! node -v v0.10.30
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the taglib package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls taglib
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/rolf/Documents/tools/node-music-player
npm ERR! node -v v0.10.30
npm ERR! npm -v 2.0.0-alpha-5
npm ERR! code ELIFECYCLE
\
> [email protected] install /Users/rolf/Documents/tools/node-music-player/node_modules/express.io/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
  SOLINK_MODULE(target) Release/bufferutil.node
  SOLINK_MODULE(target) Release/bufferutil.node: Finished
  CXX(target) Release/obj.target/validation/src/validation.o
  SOLINK_MODULE(target) Release/validation.node
  SOLINK_MODULE(target) Release/validation.node: Finished
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/rolf/Documents/tools/node-music-player/npm-debug.log
npm ERR! not ok code 0

'taglib-config' is not recognized as an internal or external command

Trying to install on Windows 8.1 (node 0.12 & iojs 2.3 both) give the following error:

'taglib-config' is not recognized as an internal or external command,

operable program or batch file.

gyp: Call to 'taglib-config --cflags' returned exit status 1. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1

(full logs (both install and debug))

0.6.0 fails to compile

Hi,
on my server env (Ubuntu with https://launchpad.net/ubuntu/oneiric/+package/libtag1-dev) I get this when upgrading to 0.6.0:


Build failed:  -> task failed (err #1):

{task: cxx bufferstream.cc -> bufferstream_1.o}

npm ERR! [email protected] preinstall: `node-waf clean || (exit 0); node-waf configure build`

npm ERR! `sh "-c" "node-waf clean || (exit 0); node-waf configure build"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the taglib package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf clean || (exit 0); node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls taglib
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 3.0.0-20-virtual
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/ubuntu/apps/myapp-node/releases/20120623000120
npm ERR! node -v v0.6.17
npm ERR! npm -v 1.1.21
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] preinstall: `node-waf clean || (exit 0); node-waf configure build`
npm ERR! message `sh "-c" "node-waf clean || (exit 0); node-waf configure build"` failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ubuntu/apps/myapp-node/releases/20120623000120/npm-debug.log
npm not ok

The version we are using is 0.3.1, but we tried to upgrade because we started getting segfaults.

Error taglib.node: undefined symbol: _ZN6TagLib8IOStreamD2Ev

Hi,
I've manually downloaded and installed node-taglib as per the instructions and I tried running the example simple script:
:~/src/node-taglib (master %) $ node examples/simple.js 01\ What's\ New.mp3

/home/username/src/node-taglib/node_modules/bindings/bindings.js:79
throw e
^
Error: /home/username/src/node-taglib/build/Release/taglib.node: undefined symbol: _ZN6TagLib8IOStreamD2Ev
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at bindings (/home/username/src/node-taglib/node_modules/bindings/bindings.js:74:15)
at Object. (/home/username/src/node-taglib/examples/simple.js:1:95)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

Running Ubuntu 12.04 with taglib 1.9.1 complied from source
$ taglib-config --version 8 ↵
1.9.1

Improve API

The current API has getAudioProperties and getFileTags which seems like a duplication of effort given the filename, and does not map cleanly onto the native TagLib API. It would be better if given a filename, an object could be retrieved which then had 'tag' and 'audioProperties' objects as properties.

Write to Buffer

Support for writing to a Buffer instead of a FileRef.

Most subclasses have a .render() method (yay!) but it looks like some (MP4) don't which sucks (sad).

Error building with Node v0.10.15 and upstream taglib

I get this output when trying to install taglib:

> [email protected] install /home/parshap/projects/album-organizer/node_modules/taglib
> node-gyp rebuild

make: Entering directory `/home/parshap/projects/album-organizer/node_modules/taglib/build'
  CXX(target) Release/obj.target/taglib/src/bufferstream.o
../src/taglib.h:26:22: warning: ‘TagLib::File* node_taglib::createFile(TagLib::IOStream*, TagLib::String)’ declared ‘static’ but never defined [-Wunused-function]
  CXX(target) Release/obj.target/taglib/src/tag.o
../src/tag.cc: In static member function ‘static v8::Handle<v8::Value> node_taglib::Tag::SyncTag(const v8::Arguments&)’:
../src/tag.cc:163:49: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
../src/tag.cc:172:124: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
../src/tag.cc: In static member function ‘static v8::Handle<v8::Value> node_taglib::Tag::AsyncTag(const v8::Arguments&)’:
../src/tag.cc:228:98: error: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
/home/parshap/.node-gyp/0.10.15/deps/uv/include/uv.h:1432:15: error:   initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../src/tag.cc: In static member function ‘static v8::Handle<v8::Value> node_taglib::Tag::AsyncSaveTag(const v8::Arguments&)’:
../src/tag.cc:291:98: error: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
/home/parshap/.node-gyp/0.10.15/deps/uv/include/uv.h:1432:15: error:   initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../src/taglib.h: At global scope:
../src/taglib.h:26:22: warning: ‘TagLib::File* node_taglib::createFile(TagLib::IOStream*, TagLib::String)’ declared ‘static’ but never defined [-Wunused-function]
../src/tag.cc:17:20: warning: ‘suseconds_t node_taglib::now()’ defined but not used [-Wunused-function]
make: *** [Release/obj.target/taglib/src/tag.o] Error 1
make: Leaving directory `/home/parshap/projects/album-organizer/node_modules/taglib/build'

I am using Node v0.10.15 and taglib/taglib@89fcab5.

can not install via npm

It seems you have put an absolute path somewhere, npm complains:

OSError: [Errno 2] No such file or directory: '/Users/nikhilmarathe/workspace/node-code/node-taglib/build'

There's been a minor problem with building from source as well:

in src/tag.cc you need to #include <string.h> for strdup in order to make it compile on my machine, which is:
Fedora 16 x64 gcc 4.6.3
This change is too smal to open a pull request imho, forgive me if mentioning that here is wrong.

compilation error - invalid conversion from ‘void (*)(uv_work_t*) ...

$ npm install taglib
npm http GET https://registry.npmjs.org/taglib
npm http 304 https://registry.npmjs.org/taglib
npm http GET https://registry.npmjs.org/bindings/1.0.0
npm http 304 https://registry.npmjs.org/bindings/1.0.0

> [email protected] install /home/andy/tmp/npmtest/node_modules/taglib
> node-gyp rebuild

make: Entering directory `/home/andy/tmp/npmtest/node_modules/taglib/build'
  CXX(target) Release/obj.target/taglib/src/bufferstream.o
In file included from ../src/bufferstream.cc:5:0:
../src/taglib.h:26:22: warning: ‘TagLib::File* node_taglib::createFile(TagLib::IOStream*, TagLib::String)’ declared ‘static’ but never defined [-Wunused-function]
  CXX(target) Release/obj.target/taglib/src/tag.o
../src/tag.cc: In static member function ‘static v8::Handle<v8::Value> node_taglib::Tag::SyncTag(const v8::Arguments&)’:
../src/tag.cc:163:49: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
../src/tag.cc:172:124: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
../src/tag.cc: In static member function ‘static v8::Handle<v8::Value> node_taglib::Tag::AsyncTag(const v8::Arguments&)’:
../src/tag.cc:228:98: error: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
In file included from /home/andy/.node-gyp/0.10.17/src/node.h:61:0,
                 from ../src/tag.h:5,
                 from ../src/tag.cc:1:
/home/andy/.node-gyp/0.10.17/deps/uv/include/uv.h:1432:15: error:   initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../src/tag.cc: In static member function ‘static v8::Handle<v8::Value> node_taglib::Tag::AsyncSaveTag(const v8::Arguments&)’:
../src/tag.cc:291:98: error: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
In file included from /home/andy/.node-gyp/0.10.17/src/node.h:61:0,
                 from ../src/tag.h:5,
                 from ../src/tag.cc:1:
/home/andy/.node-gyp/0.10.17/deps/uv/include/uv.h:1432:15: error:   initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
In file included from ../src/tag.cc:8:0:
../src/taglib.h: At global scope:
../src/taglib.h:26:22: warning: ‘TagLib::File* node_taglib::createFile(TagLib::IOStream*, TagLib::String)’ declared ‘static’ but never defined [-Wunused-function]
../src/tag.cc:17:20: warning: ‘suseconds_t node_taglib::now()’ defined but not used [-Wunused-function]
make: *** [Release/obj.target/taglib/src/tag.o] Error 1
make: Leaving directory `/home/andy/tmp/npmtest/node_modules/taglib/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.8.0-27-generic
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/andy/tmp/npmtest/node_modules/taglib
gyp ERR! node -v v0.10.17
gyp ERR! node-gyp -v v0.10.9
gyp ERR! not ok 
npm ERR! weird error 1
npm ERR! not ok code 0

$node -v
node v0.10.17

$ taglib-config --version
1.8.0

$ uname -a
Linux andyba 3.8.0-27-generic #40-Ubuntu SMP Tue Jul 9 00:17:05 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Allow callback based filetype resolver

So that something like the following can be done:

taglib.addResolvers(function(fn, cb) {
    // long I/O op
    fs.readFile(fn, function(err, data) {
        cb('mp3');
    }
}

fetching audioProperties in sync mode

Hello,
not sure I'm missing something but I see read as the method for fetching audioProperties (and the most indicated one given the amount of data to parse), however I missed something like this but sync.

does tagSync support extracting audioProperties?

Thanks.

Installation error

When I run
npm install taglib

I get:

daslicht:streams daslicht$ npm install taglib
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/taglib
npm http 200 https://registry.npmjs.org/taglib
npm http GET https://registry.npmjs.org/taglib/-/taglib-0.8.0.tgz
npm http 200 https://registry.npmjs.org/taglib/-/taglib-0.8.0.tgz
npm http GET https://registry.npmjs.org/bindings/1.0.0
npm http 200 https://registry.npmjs.org/bindings/1.0.0
npm http GET https://registry.npmjs.org/bindings/-/bindings-1.0.0.tgz
npm http 200 https://registry.npmjs.org/bindings/-/bindings-1.0.0.tgz

> [email protected] install /Users/daslicht/node_modules/taglib
> node-gyp rebuild

/bin/sh: taglib-config: command not found
gyp: Call to 'taglib-config --cflags' returned exit status 127.
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/Cellar/node/0.10.25/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Darwin 13.1.0
gyp ERR! command "node" "/usr/local/Cellar/node/0.10.25/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/daslicht/node_modules/taglib
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the taglib package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls taglib
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.1.0
npm ERR! command "/usr/local/Cellar/node/0.10.25/bin/node" "/usr/local/bin/npm" "install" "taglib"
npm ERR! cwd /Users/daslicht/node/streams
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/daslicht/node/streams/npm-debug.log
npm ERR! not ok code 0

What am I missing?

Installation failing on node v5.7.1 / Ubuntu 14.04

Trying to install the latest repository code on Ubuntu 14.04 with node.js v5.7.1 and libtag1-dev 1.2.1, I get the following failure:

npm i .
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.

> [email protected] install /home/htpc/tmp/node-taglib
> node-gyp rebuild

make: Entering directory `/home/foo/tmp/node-taglib/build'
  CXX(target) Release/obj.target/taglib/src/bufferstream.o
In file included from ../src/bufferstream.cc:5:0:
../src/taglib.h:26:43: error: ‘Arguments’ in namespace ‘v8’ does not name a type
 v8::Handle<v8::Value> AsyncReadFile(const v8::Arguments &args);
                                           ^
../src/taglib.h:26:58: error: ISO C++ forbids declaration of ‘args’ with no type [-fpermissive]
 v8::Handle<v8::Value> AsyncReadFile(const v8::Arguments &args);
                                                          ^
../src/taglib.h:46:42: error: ‘Arguments’ in namespace ‘v8’ does not name a type
 v8::Handle<v8::Value> AddResolvers(const v8::Arguments &args);
                                          ^
../src/taglib.h:46:57: error: ISO C++ forbids declaration of ‘args’ with no type [-fpermissive]
 v8::Handle<v8::Value> AddResolvers(const v8::Arguments &args);
                                                         ^
make: *** [Release/obj.target/taglib/src/bufferstream.o] Error 1
make: Leaving directory `/home/foo/tmp/node-taglib/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 3.13.0-67-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/foo/tmp/node-taglib
gyp ERR! node -v v5.7.1
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok

Won't compile with node v7.5

../src/tag.cc:239: error: ‘Loop’ was not declared in this scope

node::Loop() no longer exists in node latest. It's purpose was to support isolates in node.js. The isolate support project has been canceled in node core and as a result node::loop() no longer exists in node.h

The fix is a simple one liner. Just replace Loop() on line 239 of src/tag.cc with uv_default_loop() and this library will compile with node v7.5

Custom resolver system outside of taglib

The current mutex based system works, but it has one significant taglib level shortcoming that FileTypeResolver takes only filenames and not IOStream.

In addition, the requirement that no v8 activity occurs in a worker thread requires hacks like the mutex one currently in place. This is obviously not fun, and at some point I want to allow resolvers themselves to notify the format via a callback. Finally reading and writing from buffers using BufferStream means that JS resolvers should be able to get a buffer as an argument.

So we need our own system, that will trigger the callbacks sequentially whenever a read is attempted, then use the format string to create the right File wrapping the BufferStream.

Read TagLib AudioProperties

Hello,
is there any plan to also read and export the AudioProperties from the file?

if(!f.isNull() && f.audioProperties()) {

  TagLib::AudioProperties *properties = f.audioProperties();

  int seconds = properties->length() % 60;

  cout << "-- AUDIO --" << endl;
  cout << "bitrate     - " << properties->bitrate() << endl;
  cout << "sample rate - " << properties->sampleRate() << endl;
  cout << "channels    - " << properties->channels() << endl;
  cout << "length      - " << seconds << endl;
}

Thanks!

Thanks for your great module! I knew that TagLib was a C++ gem, but I didn't know there was a nodejs module!

Strangely it doesn't appear as result if you google "nodejs mp3". I did google "nodejs duration", which returns a Google group topic whose your answer sits at the bottom of the topic.

Anyway good job!

Too many open files

Do I need to do something to close node-taglib fd's after it has read a file? Running it on a huge dir gives TagLib: Could not open file after a while, and other file operations in my app then fail with Error: EMFILE, Too many open files.

Or are there any other suggestions on how to make sure node-taglib doesn't open more fd's than are available per process on my system?

npm install taglib fails (OS X 10.9 / Node.js v0.10.22)

npm-debug.log is at https://gist.github.com/graouts/7654784.

~ > sudo npm install taglib
npm http GET https://registry.npmjs.org/taglib
npm http 304 https://registry.npmjs.org/taglib
npm http GET https://registry.npmjs.org/bindings/1.0.0
npm http 304 https://registry.npmjs.org/bindings/1.0.0

> [email protected] install /Users/antoine/node_modules/taglib
> node-gyp rebuild

/bin/sh: taglib-config: command not found
gyp: Call to 'taglib-config --cflags' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:467:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/antoine/node_modules/taglib
gyp ERR! node -v v0.10.22
gyp ERR! node-gyp -v v0.11.0
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the taglib package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls taglib
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "taglib"
npm ERR! cwd /Users/antoine
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/antoine/npm-debug.log
npm ERR! not ok code 0
~ > node --version
v0.10.22

Unicode/UTF16 Filenames

Firstly, thanks for writing this.

With the version in npm taglib doesn't seem to like opening files with UT16 chars, just converts to ascii and attempts to read that.

sagan dekz$ node node_modules/taglib/examples/simple.js ~/Projects/node-taglib/examples/ここには何もかもがあるし、何もかもがない.mp3 
TagLib: Could not open file /Users/dekz/Projects/node-taglib/examples/SSkoU?K?K?B?WU?K?K?jD.mp3

node.js:189
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error while reading data from /Users/dekz/Projects/node-taglib/examples/SSkoU?K?K?B?WU?K?K?jD.mp3

Reading in the data is fine though:

DEBUG: { genre: '',
  artist: 'Toe',
  album: 'For Long Tomorrow',
  year: 2009,
  title: 'ここには何もかもがあるし、何もかもがない',
  track: 1 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.