feat: implement multi-provider support in media library
- Introduced IProviderRegistry to manage multiple media providers. - Updated AppState to use provider_registry instead of a single media_provider. - Refactored library routes to support provider-specific queries for collections, series, genres, and items. - Enhanced ProgrammingBlock to include provider_id for algorithmic and manual content types. - Modified frontend components to allow selection of providers and updated API calls to include provider parameters. - Adjusted hooks and types to accommodate provider-specific functionality.
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
use domain::{ContentType, IMediaProvider, MediaFilter};
|
||||
use domain::{ContentType, IProviderRegistry, MediaFilter};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::error::{domain_err, ok_json};
|
||||
|
||||
pub async fn list_collections(provider: &Arc<dyn IMediaProvider>) -> String {
|
||||
match provider.list_collections().await {
|
||||
pub async fn list_collections(registry: &Arc<infra::ProviderRegistry>) -> String {
|
||||
match registry.list_collections("").await {
|
||||
Ok(cols) => ok_json(&cols),
|
||||
Err(e) => domain_err(e),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn list_genres(
|
||||
provider: &Arc<dyn IMediaProvider>,
|
||||
registry: &Arc<infra::ProviderRegistry>,
|
||||
content_type: Option<ContentType>,
|
||||
) -> String {
|
||||
match provider.list_genres(content_type.as_ref()).await {
|
||||
match registry.list_genres("", content_type.as_ref()).await {
|
||||
Ok(genres) => ok_json(&genres),
|
||||
Err(e) => domain_err(e),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn search_media(
|
||||
provider: &Arc<dyn IMediaProvider>,
|
||||
registry: &Arc<infra::ProviderRegistry>,
|
||||
content_type: Option<ContentType>,
|
||||
genres: Vec<String>,
|
||||
search_term: Option<String>,
|
||||
@@ -36,7 +36,7 @@ pub async fn search_media(
|
||||
collections,
|
||||
..Default::default()
|
||||
};
|
||||
match provider.fetch_items(&filter).await {
|
||||
match registry.fetch_items("", &filter).await {
|
||||
Ok(items) => ok_json(&items),
|
||||
Err(e) => domain_err(e),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user