using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Scheduling; using ErsatzTV.Core.Scheduling.BlockScheduling; namespace ErsatzTV.Core.Scheduling; /// /// Builds the stateless-index for a single content entry from its /// and flat item list. /// /// Extracted (issue #395) so the Scripted engine (SchedulingEngine.EnumeratorForContent) and the /// Sequential/YAML engine (EnumeratorCache.GetEnumeratorForContent) share ONE construction switch /// instead of two byte-identical copies. Kept a public static helper with dependencies passed as /// parameters, matching the sibling / /// seams (issue #380). /// /// /// Deliberately per-family and narrow: only and /// are supported, and Shuffle maps to the block variant /// — NOT Classic's /// , which is a different algorithm. Every other order returns /// .None so each caller logs its own engine-specific "not supported" warning /// (#70); folding the warning in here would lose that per-engine message. /// /// public static class ContentEnumeratorBuilder { public static Option ForContent( List items, CollectionEnumeratorState state, PlaybackOrder playbackOrder, bool multiPart) { switch (playbackOrder) { case PlaybackOrder.Chronological: return new ChronologicalMediaCollectionEnumerator(items, state); case PlaybackOrder.Shuffle: List groupedMediaItems = multiPart ? MultiPartEpisodeGrouper.GroupMediaItems(items, false) : items.Map(mi => new GroupedMediaItem(mi, null)).ToList(); return new BlockPlayoutShuffledMediaCollectionEnumerator(groupedMediaItems, state); default: return Option.None; } } }