Search code examples
musicbrainz

Getting the official release id in MusicBrainz


I am doing the ISRC lookup for eg.

https://musicbrainz.org/ws/2/isrc/SEUM71401533?inc=releases

In the response I get list of releases. Now how do I filter the one official release. There are many official releases. I just want to get the cover art but many times its difficult to get the correct release id out of the many releases.

If I take this request for example :

https://musicbrainz.org/ws/2/isrc/SEUM71401533?inc=releases

In the response the release with the id "1c70f755-8622-41f5-8f69-9c0e8cc082ce" gives the correct album art(which is the fourth release in the response) from the covert art api doing the following request :

https://coverartarchive.org/release/1c70f755-8622-41f5-8f69-9c0e8cc082ce

So can I figure out which release id to choose programmatically so that I get the correct cover art


Solution

  • We can assume that the first release to be the official one so we can just get the first release in the response and then use its id to get the cover art.

    If there are multiple recordings we will have to get the first release across all the recordings. I am using kotlin so "min" function for arrays comes handy.

    Doing this gives me correct cover art most of the times.