Lots of fixes for track management

This commit is contained in:
Connor Johnstone
2026-03-18 13:43:52 -04:00
parent 208dbf422b
commit d09557d953
4 changed files with 41 additions and 1 deletions

View File

@@ -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,
};

View File

@@ -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())
}
}

View File

@@ -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>,
}

View File

@@ -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]