- 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.
44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
use domain::{ContentType, IProviderRegistry, MediaFilter};
|
|
use std::sync::Arc;
|
|
|
|
use crate::error::{domain_err, ok_json};
|
|
|
|
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(
|
|
registry: &Arc<infra::ProviderRegistry>,
|
|
content_type: Option<ContentType>,
|
|
) -> String {
|
|
match registry.list_genres("", content_type.as_ref()).await {
|
|
Ok(genres) => ok_json(&genres),
|
|
Err(e) => domain_err(e),
|
|
}
|
|
}
|
|
|
|
pub async fn search_media(
|
|
registry: &Arc<infra::ProviderRegistry>,
|
|
content_type: Option<ContentType>,
|
|
genres: Vec<String>,
|
|
search_term: Option<String>,
|
|
series_names: Vec<String>,
|
|
collections: Vec<String>,
|
|
) -> String {
|
|
let filter = MediaFilter {
|
|
content_type,
|
|
genres,
|
|
search_term,
|
|
series_names,
|
|
collections,
|
|
..Default::default()
|
|
};
|
|
match registry.fetch_items("", &filter).await {
|
|
Ok(items) => ok_json(&items),
|
|
Err(e) => domain_err(e),
|
|
}
|
|
}
|