Decide carefully where external::musicbrainz belongs #196

Merged
wojtek merged 11 commits from 193---decide-carefully-where-external--musicbrainz-belongs into main 2024-08-28 18:21:13 +02:00
Showing only changes of commit 57064f3b3c - Show all commits

View File

@ -1,7 +1,7 @@
//! Module for interacting with the [MusicBrainz API](https://musicbrainz.org/doc/MusicBrainz_API).
use musichoard::{
collection::{album::Album, musicbrainz::IMusicBrainzRef},
collection::album::{Album, AlbumDate},
external::musicbrainz::{
IMusicBrainzHttp, MusicBrainzClient, SearchReleaseGroupRequest,
SearchReleaseGroupResponseUnit,
@ -27,15 +27,15 @@ impl<Http: IMusicBrainzHttp> IMusicBrainz for MusicBrainz<Http> {
arid: &Mbid,
album: &Album,
) -> Result<Vec<Match<Album>>, Error> {
// Some release groups may have a promotional early release messing up the search. Searching
// with just the year should be enough anyway.
let date = AlbumDate::new(album.date.year, None, None);
let mut request = SearchReleaseGroupRequest::default();
request.arid(arid);
if let Some(ref mbref) = album.musicbrainz {
request.rgid(mbref.mbid());
} else {
request
.first_release_date(&album.date)
.release_group(&album.id.title);
}
request
.arid(arid)
.first_release_date(&date)
.release_group(&album.id.title);
let mb_response = self.client.search_release_group(request)?;