问题
How do I get ALL release groups and release dates for an artist in one call with the musicbrainz api? The closest I've been able to come to doing this is by using:
http://musicbrainz.org/ws/2/release-group?query=arid:494e8d09-f85b-4543-892f-a5096aed1cd4&fmt=json
However, some of the release groups are not there. For example, using the above call, the "EP", "Single + Remix" and some of the unofficial releases are not showing up. Basically, I'd like to be able to produce the same list that musicbrainz produces when you go to an artist's main page for "all" releases:
https://musicbrainz.org/artist/494e8d09-f85b-4543-892f-a5096aed1cd4?all=1
Also, the api call above doesn't return release dates. Any suggestions? Are these bugs? Where would be the best place to report it?
回答1:
The first thing you can do is not use the search API, which is somewhat inflexible (it doesn't support inc
parameters), but if you already know the MBID of the artist, you can simply use a browse request: https://musicbrainz.org/ws/2/release?artist=494e8d09-f85b-4543-892f-a5096aed1cd4&fmt=json&inc=release-groups
.
With the inc=release-group
parameter, you're requesting release group information for all the releases as well (you can request other information as well, check the documentation).
What you'll also notice is that, although the JSON document says "release-count": 317
, it does not actually include all of them. This is because browse requests support pagination. To get all releases, you can increase the limit (by adding limit=100
) and then doing 3 additional requests (offset=100
, offset=200
and finally offset=300
).
Your last request would therefore be to https://musicbrainz.org/ws/2/release?artist=494e8d09-f85b-4543-892f-a5096aed1cd4&fmt=json&inc=release-groups&limit=100&offset=300
(This is not a guaranteed result, but the Valentines EP appears with an offset of 100, Say Somethin' & Shake It Off with 200 and the Without You Bootleg with 300.)
Please note that the JSON Web Service is still in a beta stage - if you just change fmt=json
to fmt=xml
, you'll use the stable XML Web Service.
来源:https://stackoverflow.com/questions/27526584/musicbrainz-api-get-all-release-groups-and-release-dates