kill LibraryItem, unify to MediaItem; decouple schedule engine from providers
ADR-0001: MediaItem absorbs LibraryItem fields (provider_id, external_id, collection_name, collection_type, synced_at, role/MediaRole). LibraryItem + LibraryItemRow deleted. All ports/adapters/tests updated. ADR-0002: schedule engine takes LibraryQuery instead of IProviderRegistry. Algorithmic blocks query library via search(), manual blocks via get_by_id(). get_stream_url removed from engine; provider_registry moved to ScheduleDeps for playback-time stream URL resolution in application layer. BlockContent provider_id field removed (meaningless when querying library).
This commit is contained in:
@@ -38,7 +38,7 @@ pub async fn build_app_state(config: Config) -> anyhow::Result<AppState> {
|
||||
build_library_sync(wire_output.library_command.clone());
|
||||
|
||||
let schedule_engine = Arc::new(ScheduleEngineService::new(
|
||||
provider_registry.clone(),
|
||||
wire_output.library_query.clone(),
|
||||
wire_output.channel_query.clone(),
|
||||
wire_output.schedule_query.clone(),
|
||||
wire_output.schedule_command.clone(),
|
||||
@@ -88,6 +88,7 @@ pub async fn build_app_state(config: Config) -> anyhow::Result<AppState> {
|
||||
schedule_query: wire_output.schedule_query.clone(),
|
||||
schedule_command: wire_output.schedule_command.clone(),
|
||||
event_publisher: event_publisher.clone(),
|
||||
provider_registry: provider_registry.clone(),
|
||||
});
|
||||
|
||||
let library_command_deps = Arc::new(LibraryCommandDeps {
|
||||
@@ -475,18 +476,18 @@ impl IProviderRegistry for SimpleProviderRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
fn media_item_to_library_item(item: domain::MediaItem, provider_id: &str) -> domain::LibraryItem {
|
||||
fn provider_item_to_library_item(item: domain::MediaItem, provider_id: &str) -> domain::MediaItem {
|
||||
let external_id = item.id().value().to_string();
|
||||
let id = format!("{}::{}", provider_id, external_id);
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
|
||||
domain::LibraryItem::from_persistence(domain::LibraryItemRow {
|
||||
id,
|
||||
domain::MediaItem::from_persistence(domain::MediaItemRow {
|
||||
id: domain::MediaItemId::new(format!("{}::{}", provider_id, external_id)),
|
||||
provider_id: provider_id.to_string(),
|
||||
external_id,
|
||||
title: item.title().to_string(),
|
||||
content_type: item.content_type().clone(),
|
||||
duration_secs: item.duration_secs(),
|
||||
description: item.description().map(|s| s.to_string()),
|
||||
series_name: item.series_name().map(|s| s.to_string()),
|
||||
season_number: item.season_number(),
|
||||
episode_number: item.episode_number(),
|
||||
@@ -497,7 +498,8 @@ fn media_item_to_library_item(item: domain::MediaItem, provider_id: &str) -> dom
|
||||
collection_name: None,
|
||||
collection_type: None,
|
||||
thumbnail_url: item.thumbnail_url().map(|s| s.to_string()),
|
||||
synced_at: now,
|
||||
synced_at: Some(now),
|
||||
role: domain::MediaRole::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -558,9 +560,9 @@ impl domain::ports::LibrarySyncAdapter for SimpleSyncAdapter {
|
||||
return result;
|
||||
}
|
||||
|
||||
let library_items: Vec<domain::LibraryItem> = items
|
||||
let library_items: Vec<domain::MediaItem> = items
|
||||
.into_iter()
|
||||
.map(|item| media_item_to_library_item(item, provider_id))
|
||||
.map(|item| provider_item_to_library_item(item, provider_id))
|
||||
.collect();
|
||||
|
||||
if let Err(e) = self
|
||||
|
||||
Reference in New Issue
Block a user