Compare commits
1 Commits
208dbf422b
...
d09557d953
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d09557d953 |
@@ -11,5 +11,6 @@ pub mod provider;
|
||||
pub use error::{SearchError, SearchResult};
|
||||
pub use musicbrainz::MusicBrainzSearch;
|
||||
pub use provider::{
|
||||
AlbumResult, ArtistResult, Discography, DiscographyEntry, SearchProvider, TrackResult,
|
||||
AlbumResult, ArtistResult, Discography, DiscographyEntry, ReleaseGroupResult, SearchProvider,
|
||||
TrackResult,
|
||||
};
|
||||
|
||||
@@ -119,4 +119,22 @@ impl SearchProvider for MusicBrainzSearch {
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
|
||||
async fn get_release_groups(
|
||||
&self,
|
||||
artist_id: &str,
|
||||
) -> SearchResult<Vec<crate::provider::ReleaseGroupResult>> {
|
||||
let groups = self.client.get_artist_release_groups(artist_id).await?;
|
||||
Ok(groups
|
||||
.into_iter()
|
||||
.map(|rg| crate::provider::ReleaseGroupResult {
|
||||
id: rg.mbid,
|
||||
title: rg.title,
|
||||
primary_type: rg.primary_type,
|
||||
secondary_types: rg.secondary_types,
|
||||
first_release_date: rg.first_release_date,
|
||||
first_release_id: rg.first_release_mbid,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,4 +83,21 @@ pub trait SearchProvider: Send + Sync {
|
||||
&self,
|
||||
artist_id: &str,
|
||||
) -> impl std::future::Future<Output = SearchResult<Discography>> + Send;
|
||||
|
||||
/// Get deduplicated release groups (albums, EPs, singles) for an artist.
|
||||
fn get_release_groups(
|
||||
&self,
|
||||
artist_id: &str,
|
||||
) -> impl std::future::Future<Output = SearchResult<Vec<ReleaseGroupResult>>> + Send;
|
||||
}
|
||||
|
||||
/// A deduplicated release group (album/EP/single concept).
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ReleaseGroupResult {
|
||||
pub id: String,
|
||||
pub title: String,
|
||||
pub primary_type: Option<String>,
|
||||
pub secondary_types: Vec<String>,
|
||||
pub first_release_date: Option<String>,
|
||||
pub first_release_id: Option<String>,
|
||||
}
|
||||
|
||||
@@ -86,6 +86,10 @@ impl SearchProvider for MockSearch {
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
async fn get_release_groups(&self, _artist_id: &str) -> SearchResult<Vec<shanty_search::ReleaseGroupResult>> {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user