Code help or hint: switch from freedb API to new MB API

Previous code used freedb. i give it a freedb “DiscID” (32bit hash) and it hands back a list of discs, i pick the one i want, tell it which one, and it hands back a tracks list. quite simple.

My code currently can create the TOC data (lead out + start sectors of all songs), or if necessary i can hash together the “music brainz disc ID” (as distinct from the old freedb “DiscID”). not doing that now but if you think i need to, let me know.

so now, when i do (i think it’s) a fuzzy search like this:
https://musicbrainz.org/ws/2/discid/-?toc=1+10+169490+150+15800+34860+51180+68873+84038+98445+115918+134148+151053&fmt=json

i get back a list of “releases”, in this case, i get 12 items. but only two of them have one “media” containing one “disc”. which seems to be the list i’m looking for? i can stick’m in a menu by putting the “titles” in there, ends up looking like this:

pic

behind the scenes, the menu model tracks the “disc id”, in this case “C3ABjifq8EDMmxSSopt480krqr0-”, but then, how do i get a tracks listing with track, song name, artist, album, genre, for every track on that specific disc?
ie: what would be the cURL command to fetch the tracks from exactly one disc, and how would i specify that one disc, since even “musicbrainz disc id” can return multiple hits?

do i use the “media id” in this case “a6e38367-bb85-4c78-befa-d1fcd1d7375d” ? if i attempt a lookup with that i don’t get any track info.

Also, how do i get the artist for that disc? it doesn’t come in with the “discid” lookup…

is there doc for “how to get the same info you got using freedb” or “a programmer’s guide to musicbrainz API for those who previously used freedb” ?

2 Likes

You can use the Inc parameter to specify what additional data to include. E.g. this will contain details about artists and the track lists:

https://musicbrainz.org/ws/2/discid/-?toc=1+10+169490+150+15800+34860+51180+68873+84038+98445+115918+134148+151053&inc=artists+recordings&fmt=json

The available parameters are documented at

https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#Subqueries

7 Likes

that was quite helpful, i can now see artist info for each disc

but it’s quite confusing how to just get “track info” for a disc

it seems what i get when i fuzzy search by TOC, specifying a disc with N tracks,
what i get is a list of “release” items
and each one can have ONE or more “media” items
and each of those can have ZERO or more “disc” items (why does it bother returning those media? can i tell it NOT to?)

and SOMETIMES those discs have something OTHER than N tracks (why am i getting info on discs that don’t have the same number of tracks as what i specified in the TOC? can i tell it not to return that?)

the “freedb” ui that used to be provided on top of the musicbrainz db, used to be able to include “in the style of” artist references for “cover songs”, eg: a karaoke disc is typically a compilation of songs from various artists, and each song in the list of tracks would have a separate “artist” entry, showing the original “in the style of” artist, not the “artist” who recorded this karaoke version of the song. how would i get “original artist” ? how did the freeb ui do it?

nooooooooooooobody knoooooooooooows!

the trouble aaaaaaaaaah seeeeeeeeeeeeee

I’ve ran in to this issue before and it was a bug in my tagger for sometime before I realised it. When I “fixed” it, I didn’t question/change the parameters I was sending - I just filtered out the results myself.

1 Like

The disc entries are for the actual disc IDs that are attached to a medium. As you are doing a fuzzy search you also get results for entries that have no disc IDs attached to them. If you would lookup the actual disc ID (instead of using the dummy -) you’d get only the results that match exactly the ID, with a fallback to also include fuzzy results if the disc ID is not found.

The search is looking for matching releases, but then returns the full data for that release. If it is a multi-disc release you’ll get all of them. You’d need to filter out those.

I don’t know much about karaoke or what a “style of artist” is. But you can additional information about a release, including information about the artists who wrote the music, with a release query like:

http://musicbrainz.org/ws/2/release/3adcc155-1514-4903-b501-38464c4ce8fa?inc=recordings+work-level-rels+recording-level-rels+artist-rels+work-rels

3 Likes