Re-organized providers and added a few
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
use std::future::Future;
|
||||
|
||||
use crate::error::DataResult;
|
||||
use crate::types::{
|
||||
ArtistInfo, ArtistSearchResult, DiscographyEntry, LyricsResult, RecordingDetails,
|
||||
RecordingMatch, ReleaseGroupEntry, ReleaseMatch, ReleaseTrack,
|
||||
};
|
||||
|
||||
/// Trait for metadata lookup backends. MusicBrainz is the default implementation;
|
||||
/// others (Last.fm, Discogs, etc.) can be added later.
|
||||
pub trait MetadataFetcher: Send + Sync {
|
||||
fn search_recording(
|
||||
&self,
|
||||
artist: &str,
|
||||
title: &str,
|
||||
) -> impl Future<Output = DataResult<Vec<RecordingMatch>>> + Send;
|
||||
|
||||
fn search_release(
|
||||
&self,
|
||||
artist: &str,
|
||||
album: &str,
|
||||
) -> impl Future<Output = DataResult<Vec<ReleaseMatch>>> + Send;
|
||||
|
||||
fn get_recording(
|
||||
&self,
|
||||
mbid: &str,
|
||||
) -> impl Future<Output = DataResult<RecordingDetails>> + Send;
|
||||
|
||||
fn search_artist(
|
||||
&self,
|
||||
query: &str,
|
||||
limit: u32,
|
||||
) -> impl Future<Output = DataResult<Vec<ArtistSearchResult>>> + Send;
|
||||
|
||||
fn get_artist_releases(
|
||||
&self,
|
||||
artist_mbid: &str,
|
||||
limit: u32,
|
||||
) -> impl Future<Output = DataResult<Vec<DiscographyEntry>>> + Send;
|
||||
|
||||
fn get_release_tracks(
|
||||
&self,
|
||||
release_mbid: &str,
|
||||
) -> impl Future<Output = DataResult<Vec<ReleaseTrack>>> + Send;
|
||||
|
||||
/// Get deduplicated release groups (albums, EPs, singles) for an artist.
|
||||
fn get_artist_release_groups(
|
||||
&self,
|
||||
artist_mbid: &str,
|
||||
) -> impl Future<Output = DataResult<Vec<ReleaseGroupEntry>>> + Send;
|
||||
}
|
||||
|
||||
/// Fetches artist image URLs from an external source.
|
||||
pub trait ArtistImageFetcher: Send + Sync {
|
||||
/// Thumbnail/profile image for the artist.
|
||||
fn get_artist_image(
|
||||
&self,
|
||||
artist_info: &ArtistInfo,
|
||||
) -> impl Future<Output = DataResult<Option<String>>> + Send;
|
||||
|
||||
/// Wide banner/background image for the artist (e.g., 1920x1080).
|
||||
/// Returns None by default — providers that don't support banners need not implement this.
|
||||
fn get_artist_banner(
|
||||
&self,
|
||||
artist_info: &ArtistInfo,
|
||||
) -> impl Future<Output = DataResult<Option<String>>> + Send {
|
||||
let _ = artist_info;
|
||||
async { Ok(None) }
|
||||
}
|
||||
}
|
||||
|
||||
/// Fetches an artist biography from an external source.
|
||||
pub trait ArtistBioFetcher: Send + Sync {
|
||||
fn get_artist_bio(
|
||||
&self,
|
||||
artist_info: &ArtistInfo,
|
||||
) -> impl Future<Output = DataResult<Option<String>>> + Send;
|
||||
}
|
||||
|
||||
/// Fetches song lyrics from an external source.
|
||||
pub trait LyricsFetcher: Send + Sync {
|
||||
fn get_lyrics(
|
||||
&self,
|
||||
artist: &str,
|
||||
title: &str,
|
||||
) -> impl Future<Output = DataResult<LyricsResult>> + Send;
|
||||
}
|
||||
|
||||
/// Fetches cover art URLs for releases.
|
||||
pub trait CoverArtFetcher: Send + Sync {
|
||||
fn get_cover_art_url(&self, release_id: &str) -> Option<String>;
|
||||
}
|
||||
Reference in New Issue
Block a user