From d09557d953ee918fb83d952149f77a564b5631f3 Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Wed, 18 Mar 2026 13:43:52 -0400 Subject: [PATCH] Lots of fixes for track management --- src/lib.rs | 3 ++- src/musicbrainz.rs | 18 ++++++++++++++++++ src/provider.rs | 17 +++++++++++++++++ tests/integration.rs | 4 ++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5315f7e..4740af7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, }; diff --git a/src/musicbrainz.rs b/src/musicbrainz.rs index cff7043..f9f9011 100644 --- a/src/musicbrainz.rs +++ b/src/musicbrainz.rs @@ -119,4 +119,22 @@ impl SearchProvider for MusicBrainzSearch { .collect(), }) } + + async fn get_release_groups( + &self, + artist_id: &str, + ) -> SearchResult> { + 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()) + } } diff --git a/src/provider.rs b/src/provider.rs index 08c06a0..08f9f9f 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -83,4 +83,21 @@ pub trait SearchProvider: Send + Sync { &self, artist_id: &str, ) -> impl std::future::Future> + Send; + + /// Get deduplicated release groups (albums, EPs, singles) for an artist. + fn get_release_groups( + &self, + artist_id: &str, + ) -> impl std::future::Future>> + 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, + pub secondary_types: Vec, + pub first_release_date: Option, + pub first_release_id: Option, } diff --git a/tests/integration.rs b/tests/integration.rs index 55acba1..4ed5e7c 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -86,6 +86,10 @@ impl SearchProvider for MockSearch { ], }) } + + async fn get_release_groups(&self, _artist_id: &str) -> SearchResult> { + Ok(vec![]) + } } #[tokio::test]