adapter-jellyfin: media provider

This commit is contained in:
2026-07-12 02:47:13 +02:00
parent 72ef9b9e1b
commit e389e9e002
8 changed files with 573 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
use domain::{ContentType, MediaItem, MediaItemId};
use crate::models::JellyfinItem;
/// Ticks are Jellyfin's time unit: 1 tick = 100 nanoseconds -> 10,000,000 ticks/sec.
pub(crate) const TICKS_PER_SEC: i64 = 10_000_000;
/// Map a raw Jellyfin item to a domain `MediaItem`. Returns `None` for unknown
/// item types (e.g. Season, Series, Folder) so they are silently skipped.
pub(crate) fn map_jellyfin_item(item: JellyfinItem) -> Option<MediaItem> {
let content_type = match item.item_type.as_str() {
"Movie" => ContentType::Movie,
"Episode" => ContentType::Episode,
_ => return None,
};
let duration_secs = item
.run_time_ticks
.map(|t| (t / TICKS_PER_SEC) as u32)
.unwrap_or(0);
Some(MediaItem::from_persistence(
MediaItemId::new(item.id),
item.name,
content_type,
duration_secs,
item.overview,
item.genres.unwrap_or_default(),
item.production_year,
item.tags.unwrap_or_default(),
item.series_name,
item.parent_index_number,
item.index_number,
None, // thumbnail_url
None, // collection_id
))
}