Coder Social home page Coder Social logo

musicbrainz's Introduction

MusicBrainz

Build Status Issues NuGet Gitter

Implementation of the MusicBrainz API version 2 for .NET

Features

  • First class MusicBrainz entities Artist, ReleaseGroup, Release and Recording supporting asynchronous Get (lookup by MBID), Search and Browse.
  • Advanced Search using Lucene query syntax (see search documentation for supported fields).
  • Support for sub-queries in lookup requests (see MusicBrainz wiki for a list of supported inc parameters).
  • Limited support for entity relationships.

More information about the MusicBrainz webservice can be found here.

Examples

Take a look at the wiki or the Hqub.MusicBrainz.Client example project.

Breaking changes in v3

Version 3 removes all code that was marked obsolete in previous versions, specifically the static API and configuration. You should now use the MusicBrainzClient class instead. Take a look at the wiki or the examples!

Additionally, the .API suffix was removed from the assembly and all namespaces. Fix the namespace change by removing the .API suffix in your using statements, for example using Hqub.MusicBrainz.API now becomes using Hqub.MusicBrainz. The name change of the assembly should be automatically picked up if you are using Nuget to manage package dependencies. Otherwise, you will have to manually fix the reference in your project files.

musicbrainz's People

Contributors

avatar29a avatar gitter-badger avatar kenshintdd avatar toolboc avatar waacton avatar wo80 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

musicbrainz's Issues

Support for MusicBrainz mirror servers

Hi

I really like your MusicBrainz client implementation, keep up the good work!! The implementation lacks the possibility to run it against a MusicBrainz mirror server (). In order to do that the servername, path, port and protocol must be configurable. Is this something you have considered/rejected?

Best regards / scream4me

Support for .NET 4.0?

Hi,

is it possible to support the .NET framework 4.0? (optionnally client profile is better).

Thanks.

DNX Core

Will there be a package compatible with DNX Core?

Custom User Agent

Since the MusicBrainz service throttles based on user agent, that header value should be a custom value per application that utilizes the API. Otherwise, different and otherwise unrelated apps/users could cause others to be throttled. I have a pretty simple pull request I can send that addresses it, with logic confirmed with Fiddler2 in local use; not sure the proper automated test that would address it.

Source Code License

Could you please add a source code license file so we know what the licensing of the code is.

Increasing the accuracy of the searches

Hello all, thanks for this lovely library. After playing with it for a day I've found you can increase the accuracy of the results by changing all instances of WebUtility.UrlEncode to Uri.EscapeDataString

Here's an example, this library fails to find the correct result for Conflict - The Serenade is Dead, but if you make that change it finds it. Here are the different URLs that are produced so you can see what's happening.

First with WebUtility.UrlEncode

https://musicbrainz.org/ws/2/release?query=title%253AThe%2520Serenade%2520Is%2520Dead%2520AND%2520artist%253AConflict&limit=25&offset=0&fmt=json

Next with Uri.EscapeDataString

https://musicbrainz.org/ws/2/release?query=title%3AThe%20Serenade%20Is%20Dead%20AND%20artist%3AConflict&limit=25&offset=0&fmt=json 

The main difference seems to be how WebUtility.UrlEncode escapes the colons with %253 rather than %3A although the spaces look off also.
Anyway, thought I'd let you know and I'm happy to spin up a PR for you if you want.

A move to .NetStandard?

Hey, just wanted to say thanks for the library you've written!

Been using it for a few days (for a Proof Of Concept) now and have got quite far. Unfortunately, i've hit a stumbling block as I'd like to use it in a .NetCore application. At the moment it targets .NetFramework4.5

I've taken an hour this morning to fork the project and see how easy it would be to port.
It turns out, quite easy indeed, which is a testament to the way you've designed/built the lib!

I've got a fork here: https://github.com/ry8806/MusicBrainz/tree/netstandard-conversion
Feel free to try this out if you wish, all the tests run as per usual (all pass). As it's pretty much just a straight swap with a few *.csproj files

I'm wondering if this is something you'd be happy to PR back into this repo?
Very happy to discuss if you've got any concerns/questions about the impact on users etc

My thinking was this will enable the "next wave" of .NetCore developers to use the library, whilst still supporting the .NetFramework folks too

Let me know what your thoughts are ๐Ÿ˜„

ReleaseList is expecting `count` and `offset` but is provided `release-count` and `release-offset`

The test TestReleaseBrowseAsync() in my fork demonstrates that there is a bug with ReleaseList.Count (and undemonstrated is an issue with Offset).

The URL https://musicbrainz.org/ws/2/release?artist=c3cceeed-3332-4cf0-8c4c-bbde425147b6&limit=40&offset=0&inc=&fmt=json will return this:

{
  "releases": [
    {
...
    }
  ],
  "release-count": 448,
  "release-offset": 0
}

The code assumes it has count and offset (without the release- prefix).

Enable compression for web requests

You can enable GZip compression in WebRequestHelper.cs with just one line:

internal static T Get<T>(string url, bool withoutMetadata = true) where T : Entities.Entity
{
    try
    {
        var request = WebRequest.Create(url) as HttpWebRequest;

        request.UserAgent = "Hqub.MusicBrainze.API/1.0";
        request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

        // ...
    }
}

Portable vs .NET Standard

I was wondering if the portable project is still needed? It could be replaced by a .NET Standard 2.0 project.

There are a couple of files in the portable project though, where I'm not sure why they were added (like ImageLoader, MyHttpClient, ReadableException). I think, they should be removed and we just see if anybody wants them back.

Get artist albums by mbid

Is there a way to get artist (by mbid) main albums.

I tried using different parameters like
Artist.GetAsync(id, "works", "releases");

but nothing returned the desired results.

For example: Britney Spears
mbid: 45a663b5-b1cb-4a91-bff6-2bef7bbfdd76
image

QueryParameters() is returning a badly formatted string

I am using your example 3 and have noticed an issue with:

var query = new QueryParameters<ReleaseGroup>() { { "artist", band }, { "releasegroup", album }, { "type", "album" }, { "status", "official" } };

it is returning where it should be '%20AND%20' it is returning +AND+

my requestmessage: {https://musicbrainz.org/ws/2/release-group?query=artist%3A"Pink+Floyed"+AND+releasegroup%3A"Wish+You+Were+Here"+AND+type%3Aalbum+AND+status%3Aofficial&limit=25&offset=0&fmt=json}

which of course results in ) results found :(

Add genre entity please?

Genre was added to Musicbrainz in 2018.

It would be great if you could add genre to this library please

Project does not build

I forked the project and tried to build it, however the portable project uses links to missing files.

Can't fetch any data on AspNet Core Blazor WASM

I'm trying to use the nuget package in my Blazor WASM project. When the following code is executed

using (var client = new MusicBrainzClient()) {
    release = await client.Releases.GetAsync(id, "genres");
}

I get an exception:

System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Net.Http.BrowserHttpHandler.set_AutomaticDecompression(DecompressionMethods value)
at System.Net.Http.HttpClientHandler.set_AutomaticDecompression(DecompressionMethods value)
at Hqub.MusicBrainz.API.MusicBrainzClient.CreateHttpClient(Uri baseAddress, Boolean automaticDecompression, IWebProxy proxy)
at Hqub.MusicBrainz.API.MusicBrainzClient..ctor(String baseAddress, IWebProxy proxy)
at Hqub.MusicBrainz.API.MusicBrainzClient..ctor()
at WASM.Pages.Poster.ProcessRelease(String id)
at WASM.Pages.Poster.FileUploadedCallback(FlacFile file)
at System.Threading.Tasks.Task.<>c.b__140_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.ThreadPool.Callback()

As we can see in the trace, the exception originates here

handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

It is caused by the handler.AutomaticDecompression field setter throwing a System.PlatformNotSupportedException exception, when it is called. This behavior is explained here https://stackoverflow.com/a/52526415/6184866. It looks like HttpClientHandler is being removed from Blazor, since it is not functional in a Web Assembly.

Deserialization issues

I created a branch to add more unit tests and I'm having some deserialization issues (well, the issue is that I have no idea what's going wrong).

Have a look for example at the ReleaseTests.cs file. I'm testing

Assert.AreEqual("Official", release.Status);
Assert.AreEqual("normal", release.Quality);

The corresponding XML is

<release id="12195c41-6136-4dfd-acf1-9923dadc73e2">
    <!-- ... -->
    <status>Official</status>
    <quality>normal</quality>
    <!-- ... -->
</release>

And the serialization in Release.cs looks like

[XmlElement("status")]
public string Status { get; set; }

[XmlElement("quality")]
public string Quality { get; set; }

Now, the test of release.Status passes, but release.Quality fails because it's null (obviously it doesn't get deserialized).

So ... WTF???

Anyone got an idea?

2 calls hang

Hi,

I am trying to use your library (through nuget package latest version). I tried 2 calls but they both hang looping forever (stopped after 1 minute):

var recs = Recording.Search("the right thing");
var art=Artist.Search("Jovanotti");

I also tried the Async method, but I get the same results. Using fiddler it does not record any network traffic. Do you have any guess ?

Parameters with query

Is there a sample of how to use parameters with query? and which parameters are available.

Another thing, related or not:
For example:
var art= await Artist.GetAsync(id);

This will return artist information which is great, but I noticed many fields are return empty like
Relations = null
Rating = null
Score = 0
etc..

I am looking for a way to receive also additional data like band members (relations, score) if i provide for example- backstreet boys mbid?

Deserialization of medium-list > track-count

I'm having an issue with the following code:

var query = "artist:(giant sand) release:(tucson)";
var result = Release.Search(Uri.EscapeDataString(query), 10);

It translates to the following url:
http://musicbrainz.org/ws/2/release?query=artist%3A%28giant%20sand%29%20release%3A%28tucson%29&limit=10&offset=0

The XML returned contains the following elements:

<medium-list count="1">
  <track-count>19</track-count>
  <medium>
    <format>CD</format>
    <disc-list count="1" />
    <track-list count="19" />
  </medium>
</medium-list>

But result[i].MediumList.TrackCount is always 0.

As far as I can see, the serialization attributes of Entities.Collections.MediumList are configured correctly. Any ideas?

How to get track artist please?

Hi,

I hope someone can help me. I need to get the track artist for all tracks in a various Artist releases.

I'm using this call below to get data for a specific release. (works fine):

Client.Releases.GetAsync(pID, "recordings", "media", "release-groups", "genres")

This gives the media and media tracks (titles, TrackNo etc) but the Track.Recording does not have Credits.

Can you show me how to fetch Credits for all tracks in a release or media please. (I want the track artist)

THX

Get releases by release group id

Question,
I am using the following to get releases of a release group using:
ReleaseGroup releaseGroupList =ReleaseGroup.GetAsync(releaseGroup.Id, "artists", "releases");``
and then uses releaseGroupList.Releases with LINQ to get `Offical` status,
Is there a more elegant way to do a method?

Project changes

In my fork I'd like to change a couple of things and I'd like to know if I should add pull requests for all of them:

  1. As mentioned in issue #3, fixing the non-serialized list elements will affect a few places. I haven't compared with @deepakyadav project, but I guess it will be pretty similar.
  2. Rename the namespace form Hqub.MusicBrainze.API to Hqub.MusicBrainz.
  3. Rename APIGlobalSettings to Configuration and maybe add a few more options as static properties (e.g. web proxy).
  4. Remove url configuration from Settings.settings and add string constants to WebRequestHelper.cs.
  5. Translate any russian descriptions to english.
  6. Remove Constants.resx from Localization folder.

Let me know what you think, and I'll start making the pull requests.

CoverArtArchive always null

For every release I search, the CoverArtArchive is null.
This was not the case with the nuget version, but I can't use that one because ReleaseGroups.SearchAsync does not exist in that version...

[Question] Is there a way to hold local metadata in sync?

Hello,

great work with the library here!
I have the requirement to cache metadata local and refresh it when there are some changes.
I don't found anything on musicbrainz site to achieve something like that. (Webhooks, etc)
I have to do polling or not? That's hard work with 1 request per second :'D

Thanks.

Get by type of albums with ReleaseGroup.BrowseAsync

Hello,

Is it possible to use ReleaseGroup.BrowseAsync("artist", artistMbid, 50, 0, "ratings");
but get only albums and singles like stated in MusicBrainz api docs:
Like:
/ws/2/release-group?artist=410c9baf-5469-44f6-9852-826524b80c61&type=album|single

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.