Part ones first, on every series channel

Paul, 5 November 2026: the sequel rules for TV too. Story grouping is now on
every series channel, not just Paradox, Heroes, Orbit X, Vortex, Orbit 1
and Evidence: weighted blocks book a multi-part story whole, in order, back
to back, and a mixed show in equal turns (Riot, Orbit Junior, Dark Files,
Ring X) now keeps each story whole and in order in its shuffled deck, so a
later part never airs before its first. Replay on the box's own files over
two weeks: no later part before its part before on any channel; stories
booked back to back everywhere weighted. Committed bookings are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-05 18:18:51 +00:00
co-authored by Claude Opus 5.5
parent 8ee58095f0
commit a715a99a03
4 changed files with 129 additions and 12 deletions
@@ -194,9 +194,9 @@ internal val SmartChannels = listOf(
SuggestionRule("day", "Daytime", "Series", listOf("Animation", "Action"), 1985..2015, 7f, setOf("TV-MA"), 30),
SuggestionRule("night", "Evening", "Series", listOf("Anime", "Action"), 1985..2020, 7f, setOf("TV-MA"), 30))),
// Reads every show on its list, as the other curated channels do. Its old limit of 20 dates from when the list was short.
ChannelProgramming(201, "Terra", TerraShows, seriesCount = TerraShows.size, finishTogether = true, exactTitles = true, dayParts = TerraDayParts),
ChannelProgramming(201, "Terra", TerraShows, seriesCount = TerraShows.size, finishTogether = true, exactTitles = true, dayParts = TerraDayParts, storyGrouping = true),
ChannelProgramming(TOTS_NUMBER, "Tots", TotsShows, seriesCount = 40, finishTogether = true, exactTitles = true, dayParts = TotsDayParts, shuffleEpisodes = true,
tierWeights = TotsTiers, catalogueScaleHours = CATALOGUE_SCALE_HOURS),
tierWeights = TotsTiers, catalogueScaleHours = CATALOGUE_SCALE_HOURS, storyGrouping = true),
ChannelProgramming(106, "Paradox", ParadoxShows, seriesCount = 20, finishTogether = true, exactTitles = true, dayParts = ParadoxDayParts, shuffleTitles = (ParadoxStandalones + ParadoxAdult).toSet(),
tierWeights = ParadoxTiers, storyGrouping = true)) +
ChannelPresets.filter { it.smartOnly }.map { ChannelProgramming(it.number, it.name, it.searches, seriesCount = if (it.films) it.searches.size else 60, finishTogether = !it.films, exactTitles = true,
@@ -206,8 +206,13 @@ internal val SmartChannels = listOf(
catalogueScaleHours = if (it.number in CatalogueScaledChannels) CATALOGUE_SCALE_HOURS else null,
catalogueScaleFloor = CatalogueScaleFloors[it.number] ?: MIN_CATALOGUE_SCALE, storyGrouping = it.number in StoryGroupingChannels) }
/** Living Network Stage E: story grouping beyond Paradox, one channel at a time. Heroes first (4 November 2026): 119 story parts a week, none booked together; then Orbit X, Orbit 1 and Evidence. Vortex sets its own, above. */
private val StoryGroupingChannels get() = setOf(101, 107, 602, 603)
/**
* Living Network Stage E: story grouping beyond Paradox, one channel at a time. Heroes first (4 November 2026): 119 story parts a
* week, none booked together; then Orbit X, Orbit 1 and Evidence. Vortex, Paradox, Terra and Tots set their own, above. Every
* other series channel since 5 November 2026 (Paul: part ones first, everywhere): weighted blocks book a story whole, and a
* mixed show in equal turns keeps it whole and in order in its deck.
*/
private val StoryGroupingChannels get() = setOf(101, 102, 103, 104, 105, 107, 202, 203, 204, 401, 602, 603, 604, 605, 611)
/**
* Where a short series must keep at least half its tier's weight, so the hybrid trims its weekly repeats without cutting its
@@ -818,7 +823,7 @@ internal fun extendByBlock(pool: List<PoolSeries>, cursor: ScheduleCursor, fromM
extendWeighted(pool, tail, start, minOf(end, untilMs), weightOf, dayParts, zone, avoid, shuffle, mixed, recent, fileRestMs, stories)
} else {
val trailing = entries.lastOrNull()?.let { t -> entries.asReversed().takeWhile { it.seriesId == t.seriesId }.size } ?: runBefore
extendSchedule(pool, tail, start, minOf(end, untilMs), null, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing).let { plan ->
extendSchedule(pool, tail, start, minOf(end, untilMs), null, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing, stories = stories).let { plan ->
// Equal turns know nothing of tallies; they wait unchanged for the next weighted stretch.
plan.copy(tail = plan.tail.copy(tallies = tail.tallies, runStarted = tail.runStarted))
}
@@ -842,7 +847,11 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
/** Off only in tests: each block keeps its own place in the rotation. */
blockRotation: Boolean = true,
/** Film channels only: see [ChannelProgramming.adaptiveFilmRest]. */
adaptiveRest: Boolean = false): ChannelPlan {
adaptiveRest: Boolean = false,
/** Film channels only: see [FixedSlot]. */
fixed: List<FixedSlot> = emptyList(), held: (PoolSeries, Long) -> Boolean = { _, _ -> false },
/** Story-aware mixing (Paul, 5 November 2026: part ones first, everywhere): a mixed show keeps each multi-part story whole and in order in its deck. */
stories: Boolean = false): ChannelPlan {
require(pool.isNotEmpty() && pool.all { it.episodes.isNotEmpty() })
if (filmRestMs != null) return extendFilmSchedule(pool, cursor, fromMs, untilMs, filmRestMs, dayParts, zone, avoid, adaptiveRest)
val marks = cursor.marks.toMutableMap()
@@ -873,7 +882,7 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
}
}
fun isMixed(show: PoolSeries) = shuffle || mixed(show)
fun running(show: PoolSeries) = if (isMixed(show)) mixes.getOrPut(show.id) { shuffledEpisodes(show) } else show.episodes
fun running(show: PoolSeries) = if (isMixed(show)) mixes.getOrPut(show.id) { if (stories) shuffledStories(show, storiesOf(show)) else shuffledEpisodes(show) } else show.episodes
fun following(show: PoolSeries): PoolEpisode {
if (!isMixed(show)) return nextEpisode(show, marks[show.id])
val mix = running(show)
@@ -989,7 +998,7 @@ internal fun topUpPlan(existing: ChannelPlan?, aired: ScheduleCursor, pool: List
val added = if (weightOf != null && filmRestMs == null) {
val recent = kept?.entries.orEmpty().filter { it.startMs >= from - fileRestMs }.associate { it.media.item.id to it.startMs }
extendByBlock(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, weightOf, dayParts, zone, avoid, shuffle, mixed, finishTogether, recent, trailing, fileRestMs, stories)
} else extendSchedule(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, filmRestMs, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing, noThirdInARow, blockRotation, adaptiveRest)
} else extendSchedule(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, filmRestMs, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing, noThirdInARow, blockRotation, adaptiveRest, fixed, held, stories)
return ChannelPlan(kept?.entries.orEmpty() + added.entries, added.tail)
}