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
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 10b5b5ebfe - Show all commits

View File

@ -22,7 +22,7 @@ pub struct MbidError(String);
impl fmt::Display for MbidError { impl fmt::Display for MbidError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0) write!(f, "failed to parse a MBID: {}", self.0)
} }
} }

View File

@ -20,15 +20,16 @@ impl<Http: IMusicBrainzHttp> MusicBrainzClient<Http> {
) -> Result<LookupArtistResponse, Error> { ) -> Result<LookupArtistResponse, Error> {
let mut include: Vec<String> = vec![]; let mut include: Vec<String> = vec![];
let mbid: String = request.mbid.uuid().as_hyphenated().to_string();
if request.release_groups { if request.release_groups {
include.push(String::from("release-groups")); include.push(String::from("release-groups"));
} }
let include: String = let include: String =
form_urlencoded::byte_serialize(include.join("+").as_bytes()).collect(); form_urlencoded::byte_serialize(include.join("+").as_bytes()).collect();
let url = format!("{MB_BASE_URL}/artist/{mbid}?inc={include}"); let url = format!(
"{MB_BASE_URL}/artist/{mbid}?inc={include}",
mbid = request.mbid.uuid().as_hyphenated()
);
let response: DeserializeLookupArtistResponse = self.http.get(&url)?; let response: DeserializeLookupArtistResponse = self.http.get(&url)?;
Ok(response.into()) Ok(response.into())