Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Communicate to an Ampache server using the API
var AmpacheSession = require('ampache');
var conn = new AmpacheSession('user', 'pass', 'http://example.com/server/xml.server.php');
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
}
The dates in the above examples are JavaScript Date
objects
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": {...},
}
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"
}
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
}
The date in the above example is a JavaScript Date
object
Circumvent the built-in convenience methods and hit the api directly
conn.call_api({'action':'playlists'}, function(err, body) {
console.log(body);
});
yields
{
"1": {
"@": {
"id": "1"
},
"name": "AILD - Decas",
"owner": "Administrator",
"items": "12",
"type": "public"
},
"2": {
"@": {
"id": "2"
},
"name": "AILD - The Powerless Rise",
"owner": "Administrator",
"items": "11",
"type": "public"
}
}
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
Authenticate to the server, storing the auth data in the object, and return the body
Extend the session on the server by sending a keep-alive
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
Get a single artist/album/song by its ID on the server
Call the API directly with a given set of values to pass in
ex.
conn.call_api({'action':'ping'}, function(err, body) {});
The auth
parameter will be provided by the function if not provided
npm install ampache
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
MIT Licensed
FAQs
Communicate to an Ampache server using the API
The npm package ampache receives a total of 2 weekly downloads. As such, ampache popularity was classified as not popular.
We found that ampache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.