How to get the studio albums for an artist

query
Tags: #<Tag:0x00007fcb5747b790>

#1

I am trying to get sql query for getting an artist’s studio and live albums. The artist id is “0ab49580-c84f-44d4-875f-d83760ea2cfe” (Maroon 5). I do not wants demos or any other types. In essence I want to extract just the “Album” and “Album + Live” sections of https://musicbrainz.org/artist/0ab49580-c84f-44d4-875f-d83760ea2cfe

I believe I have found the right code here: https://github.com/metabrainz/musicbrainz-server/blob/62dee4ae7ca65b306b7aeef618037ad4bfcc380c/lib/MusicBrainz/Server/Data/ReleaseGroup.pm#L144-L169

If I pass in Maroon 5’s artist id of 66179 (eg “WHERE rg.artist_credit=66179”) I get all of their albums (I think). But how do I then determine if it is studio album, live, demo, EP, single, etc? Maybe I have the incorrect sql code. It has been quite sometime from whence I have read perl.

Thanks!


#2

Artist ID is not the same as Artist Credit ID. For example, your request doesn’t return albums credited to Maroon 5 with featuring artists.

It might be easier to use the web service instead. Maroon’s 5 albums can be retrieved every album from https://musicbrainz.org/ws/2/artist/0ab49580-c84f-44d4-875f-d83760ea2cfe?inc=release-groups with their primary and secondary types so that it can be filtered afterwards.

If you still need to make direct SQL queries, take a look at *_type tables in the database schema.