Ignore bootleg release groups #247
@ -40,18 +40,11 @@ impl<Http: IMusicBrainzHttp> MusicBrainzClient<Http> {
|
||||
) -> Result<BrowseReleaseGroupResponse, Error> {
|
||||
let entity = &request.entity;
|
||||
let mbid = request.mbid.uuid().as_hyphenated();
|
||||
let status = match request.release_group_status {
|
||||
Some(ref value) => {
|
||||
let value_str = match value {
|
||||
BrowseReleaseGroupRequestReleaseGroupStatus::WebsiteDefault => {
|
||||
"website-default"
|
||||
}
|
||||
BrowseReleaseGroupRequestReleaseGroupStatus::All => "all",
|
||||
};
|
||||
format!("&release-group-status={value_str}")
|
||||
}
|
||||
None => String::from(""),
|
||||
};
|
||||
let status = request
|
||||
.release_group_status
|
||||
.as_ref()
|
||||
.map(|s| format!("&release-group-status={s}"))
|
||||
.unwrap_or_default();
|
||||
let page = ApiDisplay::format_page_settings(paging);
|
||||
|
||||
let url = format!("{MB_BASE_URL}/release-group?{entity}={mbid}{status}{page}");
|
||||
@ -71,15 +64,24 @@ enum BrowseReleaseGroupRequestEntity {
|
||||
Artist,
|
||||
}
|
||||
|
||||
impl fmt::Display for BrowseReleaseGroupRequestEntity {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Artist => write!(f, "artist"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum BrowseReleaseGroupRequestReleaseGroupStatus {
|
||||
WebsiteDefault,
|
||||
All,
|
||||
}
|
||||
|
||||
impl fmt::Display for BrowseReleaseGroupRequestEntity {
|
||||
impl fmt::Display for BrowseReleaseGroupRequestReleaseGroupStatus {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
BrowseReleaseGroupRequestEntity::Artist => write!(f, "artist"),
|
||||
Self::WebsiteDefault => write!(f, "website-default"),
|
||||
Self::All => write!(f, "all"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,13 +95,13 @@ impl<'a> BrowseReleaseGroupRequest<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn status_website_default(mut self) -> Self {
|
||||
pub fn filter_status_website_default(mut self) -> Self {
|
||||
self.release_group_status =
|
||||
Some(BrowseReleaseGroupRequestReleaseGroupStatus::WebsiteDefault);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn status_all(mut self) -> Self {
|
||||
pub fn filter_status_all(mut self) -> Self {
|
||||
self.release_group_status = Some(BrowseReleaseGroupRequestReleaseGroupStatus::All);
|
||||
self
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ impl<Http: IMusicBrainzHttp> IMusicBrainz for MusicBrainz<Http> {
|
||||
artist: &Mbid,
|
||||
paging: &mut Option<PageSettings>,
|
||||
) -> Result<Vec<Entity<AlbumMeta>>, Error> {
|
||||
let request = BrowseReleaseGroupRequest::artist(artist).status_website_default();
|
||||
let request = BrowseReleaseGroupRequest::artist(artist).filter_status_website_default();
|
||||
|
||||
let page = paging.take().unwrap_or_default();
|
||||
let mb_response = self.client.browse_release_group(&request, &page)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user