Giter Club home page Giter Club logo

node-musicbrainz's Introduction

MusicBrainz API for node.js

Build Status

This is a MusicBrainz XML Web Service Version 2 client written in JavaScript for node.js.

It's a work in progress. Currently supports lookups with an MBID or DiscId, as well as searches for artist, release, or recording.

Contribute

Want to help make node-musicbrainz better or fix a bug? Please read How To Contribute in the wiki.

Supported resources

  • DiscId
  • Artist (recordings, releases, release-groups, works)
  • Label (releases)
  • Recording (artists, releases)
  • Release (artists, labels, recordings, release-groups)
  • Release Group (artists, releases)
  • Work

Lookup Examples

var mb = require('musicbrainz');

Looking up a release with linked artists:

mb.lookupRelease('283821f3-522a-45ca-a669-d74d0b4fb93a', ['artists'], function (error, release) {
	console.log(release);
});

The same but different:

var Release = mb.Release;

var release = new Release('283821f3-522a-45ca-a669-d74d0b4fb93a');
release.load(['artists'], function () {
	console.log(release);
});

Search Examples

mb.searchArtists('The White Stripes', {}, function(err, artists){
    console.log(artists);
});
mb.searchRecordings('Seven Nation Army', { artist: 'The White Stripes' }, function(err, recordings){
    console.log(recordings);
});
mb.searchReleases('Elephant', { country: 'US' }, function(err, releases){
    console.log(releases);
});

Configuration

If you run your own MusicBrainz server you can set a custom baseURI and and rate limit options. In the following example the API endpoint is "http://myMusicBrainzServer.org/ws/2/" and the rate limit allows 5 requests per 2 seconds.

var mb = require('musicbrainz');
mb.configure({
    baseURI: 'http://myMusicBrainzServer.org/ws/2/',
    rateLimit: {
        requests: 5,
        interval: 2000
    }
});

Caching Lookups with Redis

var mb = require('musicbrainz');
var redis = require('redis');

mb.lookupCache = function (uri, force, callback, lookup) {
	var key = 'lookup:' + uri;
	var r = redis.createClient();

	r.on('connect', function () {
		r.get(key, function (err, reply) {
			if (!err && reply) {
				callback(null, JSON.parse(reply));

			} else {
				lookup(function (err, resource) {
					callback(err, resource);

					if (err) { r.quit(); return; }

					r.set(key, JSON.stringify(resource), function (err, reply) {
						r.quit();
					});

				});
			}
		});
	});
};

Contributors

License

MIT License

Copyright (c) 2011 Max Kueng (http://maxkueng.com/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-musicbrainz's People

Contributors

alemangui avatar alexanderscott avatar ghostnumber7 avatar maxkueng 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-musicbrainz's Issues

Trickle

Trickle is not included in the repo's source code. Also trickle is not an npm package neither is this project.

Are there any plans on adding them? :)

Cheers

lookup is not defined

I'm using this under an API.
Everything works fine but sometimes I get:

{
  "code": "InternalError",
  "message": "lookup is not defined"
}

I can't event catch the error.

Certain release search fails

Intro (you can skip)

First of all, thanks for the awesome library!

I have been doing just a bit of initial research to find which library to use to fetch coverart from an album name, and I think a mix of your library and https://github.com/jbraithwaite/coverart should do the trick.

Issue

I was writing some sample code and noticed that when I ran:

var mb = require('musicbrainz');

mb.searchReleases('I\'m Not a Fan...But the Kids Like It!', {}, function(err, releases){
      console.log(releases);
});

releases is null. Despite the fact that when running a search for the exact same release on musicbrainz website it yeilds many results with the first being the exact match I am looking for. Am I doing anything wrong or is this a bug?

AcousticBrainz API Integration?

Hey,

Would it be interesting to potentially integrate the AcousticBrainz API into this project, or do you see that as out of the scope?

Basic background on AcousticBrainz if you aren't familiar with it: Universitat Pompeu Fabreau and MusicBrainz have teamed up to make this kickass DB of features for a 20m song dataset, and that API uses MusicBrainz IDs as keys for their data.

Basically it'd be a cheap addition to this library, which would add a whole other dimension to it, but on the other hand if you see it as out of scope because it's a separate API, cool :)

Documentation ?

Hi,

I'm using your module for VueJS development. Do you have a documentation/description of each functions of your module ?

Thanks in advance !

exception in searchArtists

in the callback of mb.search the length of the artist array in the artist-list array is checked.

if ('artist-list' in data && data['artist-list']['artist'].length > 0)

Sometimes MusicBrainz returns an artist-list without an artist element whatsoever.
Accessing length will then cause an exception.

The fix could be:

if ('artist-list' in data && 'artist' in data['artist-list'] && data['artist-list']['artist'].length > 0)

bug release-groups (detail)

artist reference: 09879af7-8d48-485d-8cd0-61a29d626e06
when loading release groups, an error happens:

Cannot read property '@' of undefined

configuration option

Not so much a real issue, but the uri for accessing the musicbrainz server is fixed.
People may have a local server. Therefore it might be a good idea to allow an override for this uri.
The local server could have different 'trickle' configuration too...
I have fixed this in my local js by moving both the uri and the trickle into an option object of the exports.

What about works, relationships...?

I'm doing a search by artist.

mb.searchArtists(query, filters, (err, artists) => {});

But that search is returning an empty array for works, relationships, discography...
How can I fill all that information?

Infinite loop

I am using the module in an angular project

Musicbrainz.searchReleases('Elephant', { country: 'US' }, function(err, releases){ console.log(releases); });

The snippet above results in an infinite response loop, that returns correct results, but infinitely.

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.