Hey, sorry, wanted to get back to this earlier but real life kicked in.
Things are really not that easy. Two things first: I’ll use plain web service requests here, because I’m familiar with them, but not so much with the Python library. But translating this to musicbrainzngs call should not be too difficult afterwards. Also have a look at MusicBrainz API / Search - MusicBrainz, there the different search fields and search syntax is explained.
So let’s first assume you have an artist ID. You really should do a artist search first and select one ID, otherwise it gets difficult to get good results when looking up works and recordings. In the Python library I think you can use musicbrainzngs.search_artists
for this. Snoop Dogg is a good example, because one might maybe also search for the old name “Snoop Doggy Dogg” or some of the other names he used.
Now let’s assume you have the artist ID f90e8b26-9e52-4669-a5c9-e28529c47894
. You could search for works by this artist with:
https://musicbrainz.org/ws/2/work/?query=arid:f90e8b26-9e52-4669-a5c9-e28529c47894&limit=100&fmt=json
On a first look this seems fine. But actually it lists only songs Snoop Dogg had a role in e.g. with writing. So this misses songs he performed but did not write himself (Song “Drop It Like It’s Hot” - MusicBrainz), but it also contains songs were he is listed as a writer but not performer (Song “Bomb Ass” - MusicBrainz ). Probably not exactly what’s expected.
So other approach would be to to get all the recordings by this artist and go over them, and filter out the unique works:
https://musicbrainz.org/ws/2/recording/?artist=f90e8b26-9e52-4669-a5c9-e28529c47894&inc=work-rels&limit=100&fmt=json
Note that this is what the MB web service calls a browse request (see MusicBrainz API - MusicBrainz), not a search (a search using the query
parameter).
According to the docs with musicbrainzngs this would be something like this:
result = musicbrainzngs.browse_recordings(artist="f90e8b26-9e52-4669-a5c9-e28529c47894", includes=["work-rels"], limit=limit, offset=offset)
As you can see on Song “Drop It Like It’s Hot” - MusicBrainz there are sometimes a lot of recordings for a single work (many of them probably should get merged, but often hard to say for sure), and there will be recordings not being linked to works. Not sure how to deal with them, maybe they just can be filtered out if they match the name of another recording.
Hope this helps 