Skip to content

danyal/node-spotify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

node-spotify is a node.js module to use the Spotify API in an easy manner from node.js.

The node.js module is a native module written mainly in C++.

A webpage for the project is here: http://www.node-spotify.com.

You need a spotify premium account to build or use node-spotify. This is a requirement for using libspotify, sorry. You also need an appkey that comes with a premium account (https://developer.spotify.com/technologies/libspotify/#application-keys).

Dependencies

node-gyp and libspotify are required for building. Under Linux you need libasound2-dev additionally. Install node-gyp via npm install -g node-gyp.

Your compiler must be able to translate some C++11 features (std::shared_ptr, G++ 4.7 or Clang 3.2 should do).

Compiling & installing

Compiling was tested on Raspbian, Ubuntu and OSX. Due to the usage of pthreads I'm not sure if node-spotify will compile on Windows.

There's one special option you can set when compiling node-spotify. --native_audio=false will compile no ALSA/OpenAL audio code (depending on your platform). Default is true. This is both settable for node-gyp and npm.

If you use OSX and have installed libspotify as a framework you need to edit the binding.gyp file. Remove "-lspotify" and write instead as one link option: "-framework OpenAL -framework libspotify". This is due to a bug in node-gyp that will eliminate a duplicate "-framework" entry from the link settings. If you have installed libspotify via homebrew you don't need this step.

Change into the main folder (where binding.gyp lies) and run node-gyp configure && node-gyp build.

Now the spotify module lies in ./build/Release/spotify.js. You can use it in a node.js program like so

var spotify = require('./build/Release/spotify')( {
  appkeyFile: './spotify_appkey.key'
});

The appkey file can be obtained from https://developer.spotify.com/technologies/libspotify/#application-keys (choose binary, not C-code).

How to debug node-spotify

Launch node.js and load node-spotify with require.

Attach lldb with $PID=process id of node

lldb -p $PID

Set a breakpoint with, for example

breakpoint set --file Album.cc --line 57

In the lldb console, execute this to continue the node.js process

cont

Now you can execute commands in node.js. That lead to the breakpoint.

If you want to attach additional breakpoints, interrupt the process with

process interrupt

in lldb.

Used software

About

A module for node.js to use libspotify.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 73.2%
  • C 20.2%
  • JavaScript 5.3%
  • Python 1.3%