Minor nit

This commit is contained in:
Wojciech Kozlowski 2024-08-28 15:15:29 +02:00
parent 54dee15713
commit 57064f3b3c

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)?;