From 71b7eaea112fe8b4dae7b67be659d88a70e9d8a0 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 9 Nov 2024 18:49:35 +0000 Subject: [PATCH] Fetch releases when fetching a release group --- lib/music_brainz/api_impl.ex | 231 +++++++++++++++++++++++++++-------- 1 file changed, 178 insertions(+), 53 deletions(-) diff --git a/lib/music_brainz/api_impl.ex b/lib/music_brainz/api_impl.ex index e5168636..26e562fc 100644 --- a/lib/music_brainz/api_impl.ex +++ b/lib/music_brainz/api_impl.ex @@ -14,73 +14,198 @@ defmodule MusicBrainz.APIImpl do Uses the [lookup](https://musicbrainz.org/doc/MusicBrainz_API#Lookups) endpoint with the release group id and include the artist credits. - Example request: https://musicbrainz.org/ws/2/release-group/ae504fd6-8498-463e-8d96-14f9e11d1863?fmt=json&inc=artist-credits + Example request: https://musicbrainz.org/ws/2/release-group/ae504fd6-8498-463e-8d96-14f9e11d1863?fmt=json&inc=artists+releases+genres - Example response: - - { - "artist-credit": [ - { - "artist": { - "disambiguation": "Symphonic Prog, Norway", + { + "primary-type-id": "f529b476-6e62-324f-b0aa-1f3e33d313fc", + "disambiguation": "", + "secondary-type-ids": [], + "primary-type": "Album", + "releases": [ + { + "country": "NO", "genres": [ { - "count": 3, - "disambiguation": "", + "name": "progressive rock", "id": "ae9b8279-3959-48d8-8a88-741a7f6d4a48", - "name": "progressive rock" - }, + "disambiguation": "", + "count": 1 + } + ], + "title": "Dwellers of the Deep", + "quality": "normal", + "text-representation": { + "language": null, + "script": null + }, + "packaging-id": "ec27701a-4a22-37f4-bfac-6616e0f9750a", + "disambiguation": "", + "status": "Official", + "date": "2020-10-23", + "status-id": "4e304316-386d-3409-af2e-78857eec5cfe", + "release-events": [ + { + "date": "2020-10-23", + "area": { + "type-id": null, + "id": "6743d351-6f37-3049-9724-5041161fff4d", + "name": "Norway", + "sort-name": "Norway", + "disambiguation": "", + "type": null, + "iso-3166-1-codes": [ + "NO" + ] + } + } + ], + "packaging": "Jewel Case", + "id": "ad9e5d8f-b8ff-4e3e-98be-f26cb8e0682e", + "barcode": "7090008316497" + }, + { + "genres": [ { "count": 2, "disambiguation": "", - "id": "166be36f-febb-4523-a005-1fb3603bd3f6", - "name": "symphonic prog" + "id": "93244085-20e5-4f16-9067-1d19143b3810", + "name": "classic rock" + }, + { + "name": "progressive rock", + "id": "ae9b8279-3959-48d8-8a88-741a7f6d4a48", + "disambiguation": "", + "count": 2 + }, + { + "disambiguation": "", + "name": "rock", + "id": "0e3fc579-2d24-4f20-9dae-736e1ec78798", + "count": 2 + }, + { + "name": "symphonic rock", + "id": "f729e6f8-30dc-4b81-9ff4-f4e7de82225d", + "disambiguation": "", + "count": 2 } ], - "id": "923b9160-251f-4ebe-8af2-ae670c425e55", - "name": "Wobbler", - "sort-name": "Wobbler", - "type": "Group", - "type-id": "e431f5f6-b5d2-343d-8b36-72607fffb74b" + "quality": "normal", + "title": "Dwellers of the Deep", + "country": "XW", + "release-events": [ + { + "date": "2020-10-23", + "area": { + "type-id": null, + "name": "[Worldwide]", + "id": "525d4e18-3d00-31b9-a58b-a146a916de8f", + "type": null, + "disambiguation": "", + "iso-3166-1-codes": [ + "XW" + ], + "sort-name": "[Worldwide]" + } + } + ], + "status-id": "4e304316-386d-3409-af2e-78857eec5cfe", + "id": "db32822c-27f6-4d1f-8775-df9513c04a9a", + "barcode": null, + "packaging": "None", + "packaging-id": "119eba76-b343-3e02-a292-f0f00644bb9b", + "text-representation": { + "language": "eng", + "script": "Latn" + }, + "status": "Official", + "date": "2020-10-23", + "disambiguation": "" }, - "joinphrase": "", - "name": "Wobbler" - } - ], - "disambiguation": "", - "first-release-date": "2020-10-23", - "genres": [ - { - "count": 3, - "disambiguation": "", - "id": "ae9b8279-3959-48d8-8a88-741a7f6d4a48", - "name": "progressive rock" - }, - { - "count": 1, - "disambiguation": "", - "id": "0e3fc579-2d24-4f20-9dae-736e1ec78798", - "name": "rock" - }, - { - "count": 1, - "disambiguation": "", - "id": "f729e6f8-30dc-4b81-9ff4-f4e7de82225d", - "name": "symphonic rock" - } - ], - "id": "ae504fd6-8498-463e-8d96-14f9e11d1863", - "primary-type": "Album", - "primary-type-id": "f529b476-6e62-324f-b0aa-1f3e33d313fc", - "secondary-type-ids": [], - "secondary-types": [], - "title": "Dwellers of the Deep" - } + { + "country": null, + "genres": [], + "title": "Dwellers of the Deep", + "quality": "normal", + "text-representation": { + "language": "eng", + "script": "Latn" + }, + "packaging-id": "8f931351-d2e2-310f-afc6-37b89ddba246", + "disambiguation": "", + "date": "2020-10-30", + "status": "Official", + "release-events": [ + { + "date": "2020-10-30", + "area": null + } + ], + "status-id": "4e304316-386d-3409-af2e-78857eec5cfe", + "packaging": "Digipak", + "barcode": "7090008311942", + "id": "5715243e-9c60-49bb-a1cb-4263f065f07b" + } + ], + "genres": [ + { + "id": "ae9b8279-3959-48d8-8a88-741a7f6d4a48", + "name": "progressive rock", + "disambiguation": "", + "count": 3 + }, + { + "count": 1, + "disambiguation": "", + "id": "0e3fc579-2d24-4f20-9dae-736e1ec78798", + "name": "rock" + }, + { + "count": 1, + "disambiguation": "", + "id": "f729e6f8-30dc-4b81-9ff4-f4e7de82225d", + "name": "symphonic rock" + } + ], + "secondary-types": [], + "first-release-date": "2020-10-23", + "title": "Dwellers of the Deep", + "id": "ae504fd6-8498-463e-8d96-14f9e11d1863", + "artist-credit": [ + { + "name": "Wobbler", + "joinphrase": "", + "artist": { + "disambiguation": "symphonic prog, Norway", + "type": "Group", + "sort-name": "Wobbler", + "type-id": "e431f5f6-b5d2-343d-8b36-72607fffb74b", + "id": "923b9160-251f-4ebe-8af2-ae670c425e55", + "name": "Wobbler", + "genres": [ + { + "count": 3, + "name": "progressive rock", + "id": "ae9b8279-3959-48d8-8a88-741a7f6d4a48", + "disambiguation": "" + }, + { + "name": "symphonic prog", + "id": "166be36f-febb-4523-a005-1fb3603bd3f6", + "disambiguation": "", + "count": 2 + } + ] + } + } + ] + } """ + @impl true def get_release_group(id) do url = - "https://musicbrainz.org/ws/2/release-group/#{id}?fmt=json&inc=artist-credits+genres" + "https://musicbrainz.org/ws/2/release-group/#{id}?fmt=json&inc=artists+genres+releases" json_get(url) end