npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ampache

v0.1.4

Published

Communicate to an Ampache server using the API

Downloads

19

Readme

Ampache

Communicate to an Ampache server using the API

Usage

var AmpacheSession = require('ampache');
var conn = new AmpacheSession('user', 'pass', 'http://example.com/server/xml.server.php');

Examples

Authenticate to an ampache server (assumes conn is set from the above usage)

conn.authenticate(function(err, body) {
  console.log(body);
});

yields

{
  "auth": "510b0a5f0f0e076ebab1df731acbbaeb",
  "api": "350001",
  "update": "2012-05-23T03:32:01+00:00",
  "add": "2012-08-07T09:32:17+00:00",
  "clean": "2012-08-07T09:32:29+00:00",
  "songs": "8043",
  "albums": "862",
  "artists": "372",
  "playlists": "0",
  "videos": "9"
}

Get a list of artists

conn.get_artists(function(err, body) {
  console.log(body);
});

yields

{
  "391": {
    "@": {
      "id": "391"
    },
    "name": "The American Dollar",
    "tag": {
      "#": "Post-Rock",
      "@": {
        "id": "7",
        "count": ""
      }
    },
    "albums": "2",
    "songs": "24",
    "preciserating": {},
    "rating": "0"
  },
  "392": {...},
}

Query the Ampache server for a given artist id

conn.get_artist(249, function(err, body) {
  console.log(body);
});

yields

{
  "@": {
    "id": "249"
  },
  "name": "Lights",
  "tag": {
    "#": "Pop",
    "@": {
      "id": "11",
      "count": ""
    }
  },
  "albums": "1",
  "songs": "13",
  "preciserating": {},
  "rating": "0"
}

Ping the ampache server to prolong your session

conn.ping(function(err, body) {
  console.log(body);
});

yields

{
  "session_expire": "Fri, 10 Aug 2012 07:05:09 +0000",
  "server": "3.6-Alpha1-DEV",
  "version": "350001",
  "compatible": "350001"
}

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

All callbacks are optional

conn.authenticate(callback(err, body))

Authenticate to the server, storing the auth data in the object, and return the body

conn.ping(callback(err, body))

Extend the session on the server by sending a keep-alive

conn.get_artists, conn.get_albums, conn.get_songs([search], callback(err, res))

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, callback(err, res))

Get a single artist/album/song by its ID on the server

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