Ampache
Communicate to an Ampache server using the API
Usage
var AmpacheSession = ;var conn = 'user' 'pass' 'http://example.com/server/xml.server.php';
Examples
conn
is set from the above usage)
Authenticate to an ampache server (assumes conn;
yields
The dates in the above examples are JavaScript Date
objects
Get a list of artists
conn;
yields
Query the Ampache server for a given artist id
conn;
yields
Ping the ampache server to prolong your session
conn;
yields
The date in the above example is a JavaScript Date
object
Send an api call
Circumvent the built-in convenience methods and hit the api directly
conn;
yields
Functions
new AmpacheServer(user, pass, url, [opts])
Create a new AmpacheServer
object. opts
is an object with the following keys.
opts.debug
: boolean
- defaults to false - whether to write debug messages to stderr
The following functions require an AmpacheServer
object to run
Callbacks will return an error object if applicable as the first argument, and an object representing the server response as the second.
All callbacks are optional
conn.authenticate(function(err, body))
Authenticate to the server, storing the auth data in the object, and return the body
conn.ping(function(err, body))
Extend the session on the server by sending a keep-alive
conn.get_artists, conn.get_albums, conn.get_songs([search], function(err, body))
Get a list of all artists/albums/songs on the server, returns a list of objects
search
is an optional string to filter the results
conn.get_artist, conn.get_album, conn.get_song(id, function(err, body))
Get a single artist/album/song by its ID on the server
conn.call_api(values, function(err, body))
Call the API directly with a given set of values to pass in
ex.
conn;
The auth
parameter will be provided by the function if not provided
Install
npm install ampache
Tests
To test this module, you must copy the config.json.dist
file in the tests/ folder
to config.json
, and populate it with your Ampache server credentials.
cp tests/config.json{.dist,}
$EDITOR tests/config.json
And then you can run the tests manually
npm test
License
MIT Licensed