Dealing with multi-disc releases


I’m using Python to write a program which catalogs CD’s.

I read the TOC, from that compute the discid and then use “get_releases_by_discid” which returns a big blast of data. So far so good. However, if the release involves multiple discs then I’m having trouble figuring out which disc of the multi-disc set I’m working with. For example, the Beatles “white” is a 2-disc release. Calling “get_releases_by_discid” yields the same result, other than the discid itself, for both discs and that result has, of course, two entries in the “medium-list”, one for each disc. But I’ve yet to find anything that would show me which of the two discs I asked for information on.

Continuing with the example, disc-2 has the discid ‘eCkQTx14E7sOLStFONplhtvzNSc-’ but so far I’ve not found anything in the returned data to say “that’s the second of the two entries in the medium-list”.

Any suggestions on how to do this?


Your example has many Disc ID attached (31) (and BTW it’s more convenient when you paste links instead of text), so let’s take a more simple example:

Disc ID: PuOWMzjRim2TpCIFLjB_uRB8faM-
Web Service call (I understood that’s what you want): /ws/2/discid/PuOWMzjRim2TpCIFLjB_uRB8faM-

In there, just look for your medium > disc-list > disc[id='PuOWMzjRim2TpCIFLjB_uRB8faM-'] and there you have your medium:

  <format id="9712d52a-4509-3d4b-a1a2-67c88c643e31">CD</format>
  <disc-list count="1">
    <disc id="PuOWMzjRim2TpCIFLjB_uRB8faM-">

You see it’s medium 2, not 1. :slight_smile:


Thanks for the reply.

Your example works, and the discid is there in the XML as you say. However, as I’m writing in Python, the obvious place to start seemed to be the Python module “musicbrainzngs” which claims to provide bindings for the Musicbrainz NGS webservice. The particular line of Python code I’m using to fetch the data is:

 Result = musicbrainzngs.get_releases_by_discid(DiscId, includes=["labels",'artists','recordings'])

and that works, in the sense that I get back a blast of data. However, that data does NOT include the discid inside medium > disc-list. I thought that perhaps I had to actually specify in the ‘includes’ argument that I wanted the discid (the module documentation mentions “discids” as one of the possible include values) but when I do that I get an error 400 for reasons that are not clear to me.

I can, of course, just do the Web Service call and then parse the XML myself but that is an extra level of complication that I would have avoided if the Python module had done what I wanted.


Or maybe it does. I think I was misunderstanding the “disc-list” entry. With better understanding, now I’m finding the discid in the disc-list which solves the problem. Thanks for the help!