avatar29a / musicbrainz Goto Github PK
View Code? Open in Web Editor NEWImplementation MusicBrainz API 2.0 (C#)
License: MIT License
Implementation MusicBrainz API 2.0 (C#)
License: MIT License
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 ๐
Travis CI not supported MS Test.
Error:
The type or namespace name 'Area' could not be found (are you missing a using directive or an assembly reference?)
I use the DLL. Any suggestion?
@avatar29A Could you please check if anything needs to be done for migrating from travis-ci.org to travis-ci.com.
I pushed some updates to the fluent
branch and the travis build keeps hanging in queued state.
See https://docs.travis-ci.com/user/migrate/open-source-repository-migration#migrating-a-repository.
Same applies to the LastFm project.
Thanks!
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
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.
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).
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;
// ...
}
}
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:
Hqub.MusicBrainze.API
to Hqub.MusicBrainz
.APIGlobalSettings
to Configuration
and maybe add a few more options as static properties (e.g. web proxy).Let me know what you think, and I'll start making the pull requests.
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.
Genre was added to Musicbrainz in 2018.
It would be great if you could add genre to this library please
I am looking for a way to retrieve album tracks by Album mbid.
I want to pass Album mbid and receive the tracks information including track mbid (if possible)
I am trying to get artists by tag:
like: https://beta.musicbrainz.org/tag/pop/artist
Trying to get popular artists by tag, and this seems the only way with MusicBrainz.
Can this be done with the c# implementation of the api?
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?
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?
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...
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?
I think, swallowing exceptions is never a good idea, so:
Should GenerateCommunicationThrow
be removed from Configuration
class?
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
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
I forked the project and tried to build it, however the portable project uses links to missing files.
Could you please add a source code license file so we know what the licensing of the code is.
I see several NuGet packages pointing to this page, which one is the "official" one?
https://www.nuget.org/packages/MusicBrainzWebService/
https://www.nuget.org/packages/MusicBrainzAPI/
https://www.nuget.org/packages/MusicBrainzWebService.PCL/
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.
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.
Will there be a package compatible with DNX Core?
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 :(
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 ?
Hi,
is it possible to support the .NET framework 4.0? (optionnally client profile is better).
Thanks.
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.
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
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?
When executing :
var a = await Release.GetAsync("019a762a-ef46-3dc6-aaca-ff5afc358ef2", "artists", "recordings", "ratings");
Url in which it executes:
http://beta.musicbrainz.org/ws/2/release/019a762a-ef46-3dc6-aaca-ff5afc358ef2/?inc=artists+recordings+ratings&fmt=json
I get the following error:
System.Runtime.Serialization.SerializationException: 'ValueType 'System.Int32' cannot be null.'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.