Horror TV (116): 18:00 to 06:00, off air by day, with a season rotation (build 86)
release-gate / verify (push) Successful in 12m46s
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m9s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m52s

Paul, 1 December 2026 (approved 30 November): built and switched off by default. 68 shows from the audit,
each placed by the strictest trustworthy rating of the series and its episodes: Early Evening Chills from
18:00 (nothing above TV-14; Children of the Stones, Beasts and Tales of the Unexpected checked playable),
Prime Time Terror at 21:00, The Walking Dead nightly at 23:00 on the hour, Midnight Serials at 00:00,
anthologies from 02:00 and King Weekend on Saturday and Sunday nights. Tales from the Crypt stays After
Dark's (guest only); Bradbury, Jamaica Inn and Sapphire & Steel are left out.

Planner: DayPart.offAir books nothing in its hours (the channel shows its own off-air card, the guide shows
it off air, the programme on at the start finishes), and DayPart.seasonCap is a reusable season rotation
that keeps a serial until its season is over, worked out from the saved place in each series so it
carries across restarts, top-ups and a lost schedule. Other channels are unchanged.

Look: kit logo, corner logo, palette, six block idents, ident 116 (kit ident with its own sound) and the
"Horror TV returns at 6 PM" card. Build 86 because 85 is released.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 00:29:20 +00:00
co-authored by Claude Opus 5.5
parent 5e964cc54e
commit 4faca586b9
33 changed files with 632 additions and 18 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ plugins {
id("org.jetbrains.kotlin.plugin.compose")
}
/** The release's build number: versionCode is this x 10 plus the edition's channel. */
val ORBIT_BUILD = 85
val ORBIT_BUILD = 86
android {
namespace = "tv.orbit.classic"
compileSdk = 36
@@ -87,6 +87,12 @@ internal val BlockIdents: Map<String, BlockIdent> = mapOf(
"heroeslive.feature" to BlockIdent(R.raw.block_heroeslive_feature, R.raw.block_heroeslive_feature_sting),
"heroeslive.afterdark" to BlockIdent(R.raw.block_heroeslive_afterdark, R.raw.block_heroeslive_afterdark_sting),
"heroeslive.late" to BlockIdent(R.raw.block_heroeslive_late, R.raw.block_heroeslive_late_sting),
"horrortv.early" to BlockIdent(R.raw.block_horrortv_early, R.raw.block_horrortv_early_sting),
"horrortv.strong" to BlockIdent(R.raw.block_horrortv_strong, R.raw.block_horrortv_strong_sting),
"horrortv.nightly" to BlockIdent(R.raw.block_horrortv_nightly, R.raw.block_horrortv_nightly_sting),
"horrortv.featured" to BlockIdent(R.raw.block_horrortv_featured, R.raw.block_horrortv_featured_sting),
"horrortv.anthology" to BlockIdent(R.raw.block_horrortv_anthology, R.raw.block_horrortv_anthology_sting),
"horrortv.king" to BlockIdent(R.raw.block_horrortv_king, R.raw.block_horrortv_king_sting),
"syndicate.publicenemies" to BlockIdent(R.raw.block_syndicate_publicenemies, R.raw.block_syndicate_publicenemies_sting),
"syndicate.corner" to BlockIdent(R.raw.block_syndicate_corner, R.raw.block_syndicate_corner_sting),
"syndicate.job" to BlockIdent(R.raw.block_syndicate_job, R.raw.block_syndicate_job_sting),
@@ -41,6 +41,7 @@ internal object ChannelBrands {
612 to ChannelBranding("wonder", "Orbit Wonder", R.drawable.wonder_epg, R.drawable.orbit_one_background, R.drawable.wonder_bug, ChannelCategory.Kids),
WONDER_TV_NUMBER to ChannelBranding("orbit-wonder-tv", "Wonder TV", R.drawable.orbit_wonder_tv_epg, R.drawable.orbit_one_background, R.drawable.orbit_wonder_tv_bug, ChannelCategory.Kids),
HEROES_LIVE_NUMBER to ChannelBranding("orbit-heroes-live", "Heroes Live", R.drawable.orbit_heroes_live_epg, R.drawable.orbit_one_background, R.drawable.orbit_heroes_live_bug, ChannelCategory.Entertainment),
HORROR_TV_NUMBER to ChannelBranding("orbit-horror-tv", "Horror TV", R.drawable.orbit_horror_tv_epg, R.drawable.orbit_one_background, R.drawable.orbit_horror_tv_bug, ChannelCategory.Entertainment),
613 to ChannelBranding("orbit-pixelz", "Orbit PixelZ", R.drawable.orbit_pixelz_epg, R.drawable.orbit_one_background, R.drawable.orbit_pixelz_bug, ChannelCategory.Kids),
306 to ChannelBranding("orbit-vhs", "Orbit VHS", R.drawable.orbit_vhs_epg, R.drawable.orbit_one_background, R.drawable.orbit_vhs_bug, ChannelCategory.Movies),
303 to ChannelBranding("orbit-sci-fi", "Orbit Sci-Fi", R.drawable.orbit_sci_fi_epg, R.drawable.orbit_one_background, R.drawable.orbit_sci_fi_bug, ChannelCategory.Movies),
@@ -53,6 +53,7 @@ private val Palettes: Map<Int, ChannelPalette> = mapOf(
612 to ChannelPalette(0xFFF4F0FF, longArrayOf(0xFFF6D04D, 0xFFF6D04D, 0xFF8F8CFF, 0xFF5A56C9, 0xFFF4F0FF), 0xFFF6D04D, 0xFF070A1F, 0xFF5A56C9),
WONDER_TV_NUMBER to ChannelPalette(0xFFF4F0FF, longArrayOf(0xFFF6D04D, 0xFFF6D04D, 0xFF8F8CFF, 0xFF5A56C9, 0xFFF4F0FF), 0xFFF6D04D, 0xFF070A1F, 0xFF5A56C9),
HEROES_LIVE_NUMBER to ChannelPalette(0xFFE63946, longArrayOf(0xFF1D3557, 0xFFE63946, 0xFFF4C430, 0xFF457B9D, 0xFFF1FAEE), 0xFFFFD23F, 0xFF060914, 0xFFE63946),
HORROR_TV_NUMBER to ChannelPalette(0xFFC6FF6B, longArrayOf(0xFF1F5A1C, 0xFF3F8F2F, 0xFF6FD14A, 0xFFE8E2C8, 0xFFB3121F), 0xFFE8E2C8, 0xFF030805, 0xFF4FD14A),
613 to ChannelPalette(0xFF7DFF8A, longArrayOf(0xFF2FD16B, 0xFF2FD16B, 0xFF4F7DFF, 0xFFFF4FD8, 0xFFFFE14D), 0xFFFFFFFF, 0xFF06060F, 0xFF4F7DFF),
614 to ChannelPalette(0xFFFFD970, longArrayOf(0xFFFFAB70, 0xFFFFAB70, 0xFFF7A1C4, 0xFFF7A1C4, 0xFFFFD970), 0xFFFFFFFF, 0xFF1D1430, 0xFFF7A1C4),
)
@@ -60,6 +60,8 @@ internal val ChannelPresets = listOf(
ChannelPreset(SYNDICATE_NUMBER, "SYNDICATE", SyndicateShows, smartOnly = true),
ChannelPreset(WONDER_TV_NUMBER, "Wonder TV", WonderTvShows, smartOnly = true),
ChannelPreset(HEROES_LIVE_NUMBER, "Heroes Live", HeroesLiveShows, smartOnly = true),
// Horror TV (Paul, 1 December 2026): 18:00 to 06:00, off air by day. See HorrorTv.kt.
ChannelPreset(HORROR_TV_NUMBER, "Horror TV", HorrorTvShows, smartOnly = true),
ChannelPreset(PUNCHLINE_NUMBER, "PUNCHLINE", PunchlineFilms, smartOnly = true, films = true),
ChannelPreset(CHRISTMAS_NUMBER, "Orbit Christmas", ChristmasFilms, smartOnly = true, films = true),
ChannelPreset(206, "Orbit Home", HomeShows, smartOnly = true),
@@ -55,7 +55,19 @@ internal data class DayPart(val fromHour: Int, val toHour: Int, val titles: List
/** With [typed]: a series' library identities (such as "tvdb.76168"); a pool series with a different one isn't that series. */
val seriesRefs: Map<String, Set<String>> = emptyMap(),
/** With [typed]: which of [titles] are films; every other entry is a series, even one written like a film ("Batman (1966)"). */
val filmEntries: Set<String> = emptySet()) {
val filmEntries: Set<String> = emptySet(),
/**
* Off air (Horror TV, 1 December 2026): nothing is booked in these hours. The programme on at its start finishes, then the
* channel shows its off-air card until the block ends ([offAirUntil]). Plain series channels only ([extendSchedule]).
*/
val offAir: Boolean = false,
/**
* A season rotation (Horror TV's featured serials, approved 30 November 2026): only this many of the block's series progress
* at once. A series that has started a season keeps its place until that season's last playable episode has been booked;
* then it hands over to the next waiting series in turn and goes to the back. Worked out from the channel's saved place in
* each series ([seasonRotation]), so it carries across restarts, refreshes and top-ups. 0 for none.
*/
val seasonCap: Int = 0) {
private val typedSeries by lazy { titles.filter { it !in filmEntries }.map(::seriesKey).toSet() }
private val typedFilms by lazy { titles.filter { it in filmEntries }.map(FilmIdentity::of) }
/** Whether [show] is one this block names, by type when [typed]. */
@@ -263,6 +275,9 @@ internal val ChannelDayPartSources: Map<Int, List<DayPart>> get() = mapOf(FRONTL
ChannelPresets.filter { it.smartOnly }.associate { it.number to SmartChannelParts[it.number].orEmpty() }
/** A channel's everyday blocks: its rules with no days of their own. */
/** Each channel's off-air blocks ([DayPart.offAir]), worked out once: only Horror TV has any. */
internal val OffAirBlocks: Map<Int, List<DayPart>> by lazy { ChannelDayPartSources.mapValues { (_, parts) -> parts.filter { it.offAir } }.filterValues { it.isNotEmpty() } }
internal fun everydayBlocks(number: Int): List<DayPart> = ChannelDayPartSources[number].orEmpty().filter { it.days.isEmpty() }
/** What a built-in channel plans with: its approved events from the register, then its everyday blocks. */
@@ -307,7 +322,7 @@ internal val BuiltInChannels = listOf(
channelFilms = if (it.number == 401) PpvSunday else if (it.number == ATLAS_NUMBER) AtlasFilms else if (it.number == SYNDICATE_NUMBER) SyndicateFilms else if (it.number == WONDER_TV_NUMBER) WonderTvFilms else if (it.number == HEROES_LIVE_NUMBER) HeroesLiveFilms else emptyList(), tierWeights = SmartChannelTiers[it.number], adaptiveFilmRest = it.number in AdaptiveFilmRestChannels,
// SYNDICATE (25 November 2026) books films every day, so each rests five days, as across the network.
fileRestMs = if (it.number == SYNDICATE_NUMBER || it.number == HEROES_LIVE_NUMBER) NETWORK_FILM_REST_MS else if (it.number == WONDER_TV_NUMBER) WONDER_TV_FILM_REST_MS else SAME_FILE_MS,
episodeRuns = if (it.number == HEROES_LIVE_NUMBER) HeroesLiveRuns else emptyMap(),
episodeRuns = if (it.number == HEROES_LIVE_NUMBER) HeroesLiveRuns else if (it.number == HORROR_TV_NUMBER) HorrorTvRuns else emptyMap(),
catalogueScaleHours = if (it.number in CatalogueScaledChannels) CATALOGUE_SCALE_HOURS else null,
catalogueScaleFloor = CatalogueScaleFloors[it.number] ?: MIN_CATALOGUE_SCALE, storyGrouping = it.number in StoryGroupingChannels,
shorts = if (it.number == 605) ToonZShorts else null) }
@@ -318,7 +333,7 @@ internal val BuiltInChannels = listOf(
* 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, 108, 109, 110, AMERICANA_NUMBER, STORIES_NUMBER, ATLAS_NUMBER, SYNDICATE_NUMBER, WONDER_TV_NUMBER, HEROES_LIVE_NUMBER, 202, 203, 204, 205, 206, 401, 602, 603, 604, 605, 611)
private val StoryGroupingChannels get() = setOf(101, 102, 103, 104, 105, 107, 108, 109, 110, AMERICANA_NUMBER, STORIES_NUMBER, ATLAS_NUMBER, SYNDICATE_NUMBER, WONDER_TV_NUMBER, HEROES_LIVE_NUMBER, HORROR_TV_NUMBER, 202, 203, 204, 205, 206, 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
@@ -350,7 +365,7 @@ private val SmartChannelMixed: Map<Int, Set<String>> get() = mapOf(101 to Orbit1
private val SmartChannelParts: Map<Int, List<DayPart>> get() = mapOf(101 to Orbit1DayParts, 102 to Orbit2DayParts, 103 to ThreeDayParts, 104 to GoldDayParts, 105 to RiotDayParts, 304 to HorrorDayParts,
602 to HeroesDayParts, 603 to OrbitXDayParts, 604 to RewindDayParts, 605 to ToonZDayParts, 204 to DarkFilesDayParts, 203 to WildDayParts, 202 to OdysseyDayParts, 107 to EvidenceDayParts,
401 to RingXDayParts, 611 to JuniorDayParts, 205 to KitchenDayParts, 206 to HomeDayParts, 108 to PlayDayParts,
109 to SignatureDayParts, 110 to UnscriptedDayParts, CHRISTMAS_NUMBER to ChristmasDayParts, AMERICANA_NUMBER to AmericanaDayParts, ATLAS_NUMBER to AtlasDayParts, SYNDICATE_NUMBER to SyndicateDayParts, PUNCHLINE_NUMBER to PunchlineDayParts, WONDER_NUMBER to WonderDayParts, WONDER_TV_NUMBER to WonderTvDayParts, HEROES_LIVE_NUMBER to HeroesLiveDayParts, OUTLAW_NUMBER to OutlawDayParts, SILVER_SCREEN_NUMBER to SilverScreenDayParts, STORIES_NUMBER to StoriesDayParts)
109 to SignatureDayParts, 110 to UnscriptedDayParts, CHRISTMAS_NUMBER to ChristmasDayParts, AMERICANA_NUMBER to AmericanaDayParts, ATLAS_NUMBER to AtlasDayParts, SYNDICATE_NUMBER to SyndicateDayParts, PUNCHLINE_NUMBER to PunchlineDayParts, WONDER_NUMBER to WonderDayParts, WONDER_TV_NUMBER to WonderTvDayParts, HEROES_LIVE_NUMBER to HeroesLiveDayParts, HORROR_TV_NUMBER to HorrorTvDayParts, OUTLAW_NUMBER to OutlawDayParts, SILVER_SCREEN_NUMBER to SilverScreenDayParts, STORIES_NUMBER to StoriesDayParts)
/** Optional bigger pools, only used once reviewed. No rule for Orbit Gold or Orbit Three: nothing in the library's details can tell a British sitcom apart. */
private val SmartChannelRules: Map<Int, List<SuggestionRule>> get() = mapOf(
@@ -506,6 +521,33 @@ internal fun withinRuns(series: List<PoolSeries>, runs: Map<String, EpisodeMark>
s.copy(episodes = s.episodes.filter { e -> e.mark.season < last.season || (e.mark.season == last.season && e.mark.episode <= last.episode) }).takeIf { it.episodes.isNotEmpty() } }
}
/** Whether [show] is part way through a season: its last booked episode isn't its season's last playable one. */
internal fun midSeason(show: PoolSeries, last: EpisodeMark?): Boolean =
last != null && show.episodes.any { it.mark.season == last.season && it.mark.episode > last.episode }
/**
* Which of a season rotation's [shows] may be booked next ([DayPart.seasonCap]). Every series part way through a season stays
* (no season is ever left unfinished); the rest of the places go to the series next in turn after [after], the block's last
* booked show, so a series that has just finished its season goes to the back. Nothing is stored apart from the channel's
* place in each series ([marks]) and the block's last show, both already saved with the plan and with the aired place.
*/
internal fun seasonRotation(shows: List<PoolSeries>, cap: Int, marks: Map<String, EpisodeMark>, after: String?,
/** Whether a waiting series may start now: on a channel whose shows finish together, not one that has finished its run. */
ready: (PoolSeries) -> Boolean = { true }): Set<String> {
val running = shows.filter { midSeason(it, marks[it.id]) }
if (running.size >= cap) return running.mapTo(HashSet()) { it.id }
val waiting = turnOrder(shows, after).filter { it !in running && ready(it) }
return (running + waiting.take(cap - running.size)).mapTo(HashSet()) { it.id }
}
/** When the off-air block covering [startMs] ends: the local hour the channel is back on. */
internal fun offAirEnd(part: DayPart, startMs: Long, zone: java.time.ZoneId): Long {
val local = java.time.Instant.ofEpochMilli(startMs).atZone(zone)
var end = local.toLocalDate().atTime(part.toHour % 24, 0).atZone(zone)
if (!end.isAfter(local)) end = end.plusDays(1)
return end.toInstant().toEpochMilli()
}
/** A few names and how many more, so a reason stays short. */
private fun someOf(names: List<String>) = names.take(3).joinToString(", ") + if (names.size > 3) " +${names.size - 3}" else ""
@@ -1148,14 +1190,18 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
var slot: ShortsSlot? = null
while (start < untilMs) {
val (available, block, part) = partAt(start)
// Off air: nothing booked until the block ends. The programme already on finishes first.
if (part?.offAir == true) { start = offAirEnd(part, start, zone); continue }
// Shows only wait for others in the same block, or a daytime show could stand idle for an evening one.
val restarted = finishTogether && available.all { marks[it.id] == running(it).last().mark }
if (restarted) available.forEach { marks.remove(it.id) }
val allowed = { show: PoolSeries -> show in available && (!finishTogether || marks[show.id] != running(show).last().mark) }
// Skips a show already on elsewhere, unless that would leave nothing to show.
val waiting = mutableListOf<String>(); val elsewhere = mutableListOf<String>()
// A block carries on from its own last show. Starting from the channel's last show would begin each block at the same place every day.
val after = if (blockRotation) blockLast[block] ?: last else last
// A season rotation: only the series it has running, or next in turn for a free place.
val season = if (part != null && part.seasonCap > 0) seasonRotation(available, part.seasonCap, marks, after) { !finishTogether || marks[it.id] != running(it).last().mark } else null
val allowed = { show: PoolSeries -> show in available && (season == null || show.id in season) && (!finishTogether || marks[show.id] != running(show).last().mark) }
// Skips a show already on elsewhere, unless that would leave nothing to show.
val waiting = mutableListOf<String>(); val elsewhere = mutableListOf<String>()
// Inside a shorts slot, the next short in turn that fits it; none fits, and the slot closes where it is.
fun slotPick(open: ShortsSlot) = open.varied(turnOrder(pool, after).filter { show -> show.id != last && allowed(show) && open.takes(start, following(show).durationMs) && !avoid(show, start, start + following(show).durationMs) }) { it.id }
val inSlot = slot?.let { open -> slotPick(open) ?: if (open.stretchIfShort(start)) slotPick(open) else null }
@@ -1164,7 +1210,7 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
val onward = if (marathon > 1 && run in 1 until marathon) available.firstOrNull { it.id == last && !avoid(it, start, start + following(it).durationMs) } else null
val picked = onward ?: inSlot ?: turnOrder(pool, after).firstOrNull { show ->
when {
!allowed(show) -> { if (show in available) waiting += show.title; false }
!allowed(show) -> { if (show in available && (season == null || show.id in season)) waiting += show.title; false }
avoid(show, start, start + following(show).durationMs) -> { elsewhere += show.title; false }
else -> true
}
@@ -1205,6 +1251,7 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
else -> "; fallback: every show in turn airs elsewhere then"
})
if (isMixed(series)) append(", episode from its shuffled order")
if (season != null) append("; season rotation, ${season.size} running")
if (fitted) append("; chosen to finish before the appointment at ${java.time.Instant.ofEpochMilli(appointment!!).atZone(zone).toLocalTime()}")
if (restarted) append("; every show had finished, so all started again")
if (waiting.isNotEmpty()) append("; deferred until the rest finish: ${someOf(waiting)}")
@@ -1288,6 +1335,7 @@ internal fun topUpPlan(existing: ChannelPlan?, aired: ScheduleCursor, pool: List
if (kept != null && kept.endMs >= nowMs + SCHEDULE_TOP_UP_MS) return kept
if (pool.isNullOrEmpty()) return kept
@Suppress("NAME_SHADOWING") val dayParts = resolveRotations(dayParts, pool, nowMs, zone)
require((weightOf == null && filmRestMs == null) || dayParts.none { it.offAir || it.seasonCap > 0 }) { "Off-air blocks and season rotations are for plain series channels." }
val from = if (kept != null && kept.endMs > nowMs) kept.endMs else nowMs
val untilMs = minOf(nowMs + SCHEDULE_AHEAD_MS, seasonEndMs ?: Long.MAX_VALUE)
if (from >= untilMs) return kept ?: ChannelPlan(emptyList(), existing?.tail ?: aired)
@@ -1379,6 +1427,12 @@ internal class ScheduledChannel(val loop: SampleChannel, plan: ChannelPlan) : Sa
}
// Between plans the loop fills in, cut short so it never runs over the next planned programme.
val fill = loop.at(timeMs)
// Off air (Horror TV by day): from the end of the last programme, so nothing of the loop is shown as on air.
val previous = entries.getOrNull(low - 1)
if (previous != null && OffAirBlocks.containsKey(number) && offAirUntil(number, timeMs) != null) {
val end = entries.getOrNull(low)?.startMs ?: (timeMs + 60 * 60_000L)
return SampleBroadcast(fill.media.copy(durationMs = end - previous.endMs), previous.endMs)
}
val next = entries.getOrNull(low) ?: return fill
if (fill.endMs <= next.startMs) return fill
return fill.copy(media = fill.media.copy(durationMs = next.startMs - fill.startMs))
@@ -316,9 +316,17 @@ internal fun qrBitmap(text: String, size: Int): androidx.compose.ui.graphics.Ima
}
private fun android.graphics.Bitmap.asImageBitmapCompat(): androidx.compose.ui.graphics.ImageBitmap = asImageBitmap()
/** A channel of your own outside its hours: its name, and when it's back. */
/** A channel's own off-air card, where it has one: Horror TV's "returns at 6 PM" (Paul, 30 November 2026). */
internal val OffAirPictures = mapOf(HORROR_TV_NUMBER to R.drawable.orbit_horror_tv_offair)
/** A channel off air: its own card where it has one, otherwise its name and when it's back (a channel of your own outside its hours). */
@Composable
internal fun OffAirCard(channel: SampleChannel, back: String) {
OffAirPictures[channel.number]?.let { picture ->
androidx.compose.foundation.Image(androidx.compose.ui.res.painterResource(picture), "${channel.name}. Off air. $back.",
Modifier.fillMaxSize().background(Color.Black), contentScale = androidx.compose.ui.layout.ContentScale.Fit)
return
}
Box(Modifier.fillMaxSize().background(Navy), contentAlignment = Alignment.Center) {
StarrySky()
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(10.dp)) {
@@ -144,10 +144,14 @@ internal fun timetableParts(titles: List<String>): List<DayPart> {
return (0 until 12).map { k -> val from = (6 + k * 2) % 24; DayPart(from, (from + 2) % 24, listOf(titles[k % titles.size]), group = "timetable") }
}
/** "Back at 18:00" when a channel of your own is outside its hours at [timeMs]; null when it's on. */
/**
* "Back at 18:00" when a channel is off air at [timeMs]: a channel of your own outside its hours, or a channel in an off-air
* block ([DayPart.offAir], Horror TV by day). Null when it's on. A programme is on air when it starts in the channel's hours.
*/
internal fun offAirUntil(number: Int, timeMs: Long, zone: ZoneId = ZoneId.systemDefault()): String? {
val hours = CustomChannels.of(number)?.hours ?: return null
val hour = Instant.ofEpochMilli(timeMs).atZone(zone).hour
OffAirBlocks[number]?.firstOrNull { it.covers(hour) }?.let { return "Back at %02d:00".format(it.toHour % 24) }
val hours = CustomChannels.of(number)?.hours ?: return null
return if (hours.covers(hour)) null else "Back at %02d:00".format(hours.fromHour)
}
@@ -0,0 +1,216 @@
package tv.orbit.classic
/**
* Horror TV (116): horror television from 18:00 to 06:00, off air by day (Paul, 1 December 2026: build it, switched off by
* default; approved 30 November). Like old-school cable, it closes down at 06:00 and "returns at 6 PM", rather than filling
* the day with repeats. Generated from the audit (audit-20261201-horrortv-build/gen.py).
*
* - 18:00 Early evening: classic suspense and gentler horror, nothing above TV-14 (Children of the Stones, Beasts and Tales
* of the Unexpected among them).
* - 21:00 Stronger: TV-14 horror drama and anthologies.
* - 23:00 The Walking Dead, nightly, in order, on the hour: what comes before is chosen to finish in time.
* - 00:00 Featured serials: a season rotation ([DayPart.seasonCap]), a few serials at a time, each handing over only once its
* season has finished.
* - 02:00 Anthologies; on Saturday and Sunday nights, Stephen King specials. Tales from the Crypt is After Dark's, here as an
* approved guest, never at the same moment.
*
* Every show is placed by its most restrictive trustworthy rating, its own or any of its episodes' ([HorrorTvRatings]): TV-MA
* only from 23:00. Serials stop before their first missing episode ([HorrorTvRuns]); anthologies and episodic shows play every
* playable episode. Left out: Sapphire & Steel (incomplete), The Ray Bradbury Theater (Paradox's review), Jamaica Inn
* (Orbit Showcase's review), and the mysteries that are Evidence's.
*/
internal const val HORROR_TV_NUMBER = 116
/** 18:00 to 21:00. */
private val HorrorTvEarly = listOf(
"The Alfred Hitchcock Hour", "Alfred Hitchcock Presents", "Kolchak: The Night Stalker", "Amazing Stories (1985)",
"A Ghost Story for Christmas", "Wellington Paranormal", "Children of the Stones", "Beasts", "Tales of the Unexpected")
/** 21:00 to 23:00. */
private val HorrorTvStrong = listOf(
"Scream: The TV Series", "Scream Queens", "Freddy's Nightmares", "The Exorcist", "Fear Itself", "Salem's Lot (2004)",
"Stephen King's It", "Two Sentence Horror Stories")
/** 23:00 to midnight. */
private val HorrorTvNightly = listOf("The Walking Dead")
/** Midnight to 02:00, in a season rotation. */
internal val HorrorTvFeatured = listOf(
"American Horror Story", "Hannibal", "Penny Dreadful", "The Terror", "Bates Motel", "Ash vs Evil Dead", "Chucky", "Servant",
"Yellowjackets", "FROM", "The Strain", "Z Nation", "Fear the Walking Dead", "Castle Rock", "Salem", "Hemlock Grove",
"Interview With The Vampire", "Midnight Mass", "The Haunting", "Lovecraft Country", "Channel Zero", "Black Summer",
"Kingdom (2019)", "Sweet Home", "The Uncanny Counter", "The Outsider (2020)", "IT: Welcome to Derry", "Wolf Creek", "Damien",
"What We Do in the Shadows", "Santa Clarita Diet")
/** 02:00 to 06:00. */
private val HorrorTvAnthology = listOf(
"Creepshow", "Guillermo del Toro's Cabinet of Curiosities", "Monsterland", "Nightmares and Daydreams",
"Hammer House of Horror", "The Hitchhiker", "American Horror Stories",
"Nightmares & Dreamscapes: From the Stories of Stephen King", "Tales from the Crypt", "Friday the 13th: The Series")
/** Saturday and Sunday nights, 02:00 to 06:00. */
private val HorrorTvKing = listOf(
"The Stand", "The Stand (2020)", "Storm of the Century", "Kingdom Hospital", "Lisey's Story", "The Shining", "Chapelwaite",
"The Institute", "Carrie")
internal val HorrorTvShows get() = HorrorTvEarly + HorrorTvStrong + HorrorTvNightly + HorrorTvFeatured + HorrorTvAnthology + HorrorTvKing
/** How many featured serials run at once. */
internal const val HORROR_TV_FEATURED_AT_ONCE = 4
/** Each show's most restrictive trustworthy rating, its own or any episode's (the audit, 1 December 2026). */
internal val HorrorTvRatings: Map<String, String> by lazy { mapOf(
"The Alfred Hitchcock Hour" to "TV-PG",
"Alfred Hitchcock Presents" to "TV-14",
"Kolchak: The Night Stalker" to "TV-PG",
"Amazing Stories (1985)" to "TV-PG",
"A Ghost Story for Christmas" to "TV-PG",
"Wellington Paranormal" to "TV-14",
"Children of the Stones" to "TV-PG",
"Beasts" to "GB-12",
"Tales of the Unexpected" to "TV-14",
"Scream: The TV Series" to "TV-14",
"Scream Queens" to "TV-14",
"Freddy's Nightmares" to "TV-14",
"The Exorcist" to "TV-14",
"Fear Itself" to "TV-14",
"Salem's Lot (2004)" to "TV-14",
"Stephen King's It" to "TV-14",
"Two Sentence Horror Stories" to "TV-14",
"The Walking Dead" to "TV-MA",
"American Horror Story" to "TV-MA",
"Hannibal" to "TV-MA",
"Penny Dreadful" to "TV-MA",
"The Terror" to "TV-MA",
"Bates Motel" to "TV-MA",
"Ash vs Evil Dead" to "TV-MA",
"Chucky" to "TV-MA",
"Servant" to "TV-MA",
"Yellowjackets" to "TV-MA",
"FROM" to "TV-MA",
"The Strain" to "TV-MA",
"Z Nation" to "TV-MA",
"Fear the Walking Dead" to "TV-MA",
"Castle Rock" to "TV-MA",
"Salem" to "TV-MA",
"Hemlock Grove" to "TV-MA",
"Interview With The Vampire" to "TV-MA",
"Midnight Mass" to "TV-MA",
"The Haunting" to "TV-MA",
"Lovecraft Country" to "TV-MA",
"Channel Zero" to "TV-MA",
"Black Summer" to "TV-MA",
"Kingdom (2019)" to "TV-MA",
"Sweet Home" to "TV-MA",
"The Uncanny Counter" to "16",
"The Outsider (2020)" to "TV-MA",
"IT: Welcome to Derry" to "TV-MA",
"Wolf Creek" to "TV-MA",
"Damien" to "TV-MA",
"What We Do in the Shadows" to "TV-MA",
"Santa Clarita Diet" to "TV-MA",
"Creepshow" to "TV-MA",
"Guillermo del Toro's Cabinet of Curiosities" to "18+",
"Monsterland" to "TV-MA",
"Nightmares and Daydreams" to "TV-MA",
"Hammer House of Horror" to "TV-MA",
"The Hitchhiker" to "ES-16",
"American Horror Stories" to "TV-MA",
"Nightmares & Dreamscapes: From the Stories of Stephen King" to "TV-MA",
"Tales from the Crypt" to "TV-MA",
"Friday the 13th: The Series" to "TV-MA",
"The Stand" to "TV-MA",
"The Stand (2020)" to "TV-MA",
"Storm of the Century" to "TV-MA",
"Kingdom Hospital" to "TV-MA",
"Lisey's Story" to "TV-MA",
"The Shining" to "TV-MA",
"Chapelwaite" to "TV-MA",
"The Institute" to "TV-MA",
"Carrie" to "TV-MA") }
/** Serials with a gap: where their playable run ends. */
internal val HorrorTvRuns: Map<String, EpisodeMark> = mapOf()
/** Each series' library identity (TVDB and IMDb IDs), so a show is matched by what it is, not only its name. */
internal val HorrorTvSeriesRefs: Map<String, Set<String>> by lazy { mapOf(
"The Alfred Hitchcock Hour" to setOf("imdb.tt0055657", "tvdb.74488"),
"Alfred Hitchcock Presents" to setOf("imdb.tt0047708", "tvdb.73614"),
"Kolchak: The Night Stalker" to setOf("imdb.tt0071003", "tvdb.74463"),
"Amazing Stories (1985)" to setOf("imdb.tt0088478", "tvdb.76149"),
"A Ghost Story for Christmas" to setOf("imdb.tt32135296", "tvdb.153381"),
"Wellington Paranormal" to setOf("imdb.tt6109562", "tvdb.344280"),
"Children of the Stones" to setOf("imdb.tt0075491", "tvdb.71832"),
"Beasts" to setOf("imdb.tt0169416", "tvdb.73781"),
"Tales of the Unexpected" to setOf("imdb.tt0075592", "tvdb.78710"),
"Scream: The TV Series" to setOf("imdb.tt3921180", "tvdb.294417"),
"Scream Queens" to setOf("imdb.tt4145384", "tvdb.293302"),
"Freddy's Nightmares" to setOf("imdb.tt0094466", "tvdb.71521"),
"The Exorcist" to setOf("imdb.tt5368542", "tvdb.311816"),
"Fear Itself" to setOf("imdb.tt1112285", "tvdb.82120"),
"Salem's Lot (2004)" to setOf("imdb.tt0355987", "tvdb.153321"),
"Stephen King's It" to setOf("imdb.tt0099864", "tvdb.113981"),
"Two Sentence Horror Stories" to setOf("imdb.tt6873926", "tvdb.337660"),
"The Walking Dead" to setOf("imdb.tt1520211", "tvdb.153021"),
"American Horror Story" to setOf("imdb.tt1844624", "tvdb.250487"),
"Hannibal" to setOf("imdb.tt2243973", "tvdb.259063"),
"Penny Dreadful" to setOf("imdb.tt2628232", "tvdb.265766"),
"The Terror" to setOf("imdb.tt2708480", "tvdb.322191"),
"Bates Motel" to setOf("imdb.tt2188671", "tvdb.262414"),
"Ash vs Evil Dead" to setOf("imdb.tt4189022", "tvdb.296295"),
"Chucky" to setOf("imdb.tt8388390", "tvdb.349415"),
"Servant" to setOf("imdb.tt8068860", "tvdb.368126"),
"Yellowjackets" to setOf("imdb.tt11041332", "tvdb.399731"),
"FROM" to setOf("imdb.tt9813792", "tvdb.401003"),
"The Strain" to setOf("imdb.tt2654620", "tvdb.276564"),
"Z Nation" to setOf("imdb.tt3843168", "tvdb.280494"),
"Fear the Walking Dead" to setOf("imdb.tt3743822", "tvdb.290853"),
"Castle Rock" to setOf("imdb.tt6548228", "tvdb.331600"),
"Salem" to setOf("imdb.tt2963254", "tvdb.274897"),
"Hemlock Grove" to setOf("imdb.tt2309295", "tvdb.259948"),
"Interview With The Vampire" to setOf("imdb.tt3960394", "tvdb.405535"),
"Midnight Mass" to setOf("imdb.tt10574558", "tvdb.367226"),
"The Haunting" to setOf("imdb.tt6763664", "tvdb.345246"),
"Lovecraft Country" to setOf("imdb.tt6905686", "tvdb.357864"),
"Channel Zero" to setOf("imdb.tt4820370", "tvdb.315178"),
"Black Summer" to setOf("imdb.tt8923854", "tvdb.350587"),
"Kingdom (2019)" to setOf("imdb.tt6611916", "tvdb.355228"),
"Sweet Home" to setOf("imdb.tt11612120", "tvdb.374389"),
"The Uncanny Counter" to setOf("imdb.tt13273826", "tvdb.389855"),
"The Outsider (2020)" to setOf("imdb.tt8550800", "tvdb.365480"),
"IT: Welcome to Derry" to setOf("imdb.tt19244304", "tvdb.418424"),
"Wolf Creek" to setOf("imdb.tt4460878", "tvdb.310223"),
"Damien" to setOf("imdb.tt4337944", "tvdb.282165"),
"What We Do in the Shadows" to setOf("imdb.tt7908628", "tvdb.358211"),
"Santa Clarita Diet" to setOf("imdb.tt5580540", "tvdb.320450"),
"Creepshow" to setOf("imdb.tt8762206", "tvdb.364865"),
"Guillermo del Toro's Cabinet of Curiosities" to setOf("imdb.tt8415836", "tvdb.409559"),
"Monsterland" to setOf("imdb.tt10404698", "tvdb.385960"),
"Nightmares and Daydreams" to setOf("imdb.tt21962590", "tvdb.445602"),
"Hammer House of Horror" to setOf("imdb.tt0080231", "tvdb.76799"),
"The Hitchhiker" to setOf("imdb.tt0085031", "tvdb.78513"),
"American Horror Stories" to setOf("imdb.tt12306692", "tvdb.382187"),
"Nightmares & Dreamscapes: From the Stories of Stephen King" to setOf("imdb.tt0481452", "tvdb.79389"),
"Tales from the Crypt" to setOf("imdb.tt0096708", "tvdb.73029"),
"Friday the 13th: The Series" to setOf("imdb.tt0092357", "tvdb.73804"),
"The Stand" to setOf("imdb.tt0108941", "tvdb.79866"),
"The Stand (2020)" to setOf("imdb.tt1831804", "tvdb.359583"),
"Storm of the Century" to setOf("imdb.tt0135659", "tvdb.85538"),
"Kingdom Hospital" to setOf("imdb.tt0324864", "tvdb.78951"),
"Lisey's Story" to setOf("imdb.tt3319460", "tvdb.366527"),
"The Shining" to setOf("imdb.tt0118460", "tvdb.80245"),
"Chapelwaite" to setOf("imdb.tt11525188", "tvdb.382426"),
"The Institute" to setOf("imdb.tt10946316", "tvdb.451177"),
"Carrie" to setOf("imdb.tt11540908", "tvdb.455755")) }
internal val HorrorTvDayParts: List<DayPart> get() {
val refs = HorrorTvSeriesRefs
return listOf(
DayPart(2, 6, HorrorTvKing, group = "King", days = setOf(java.time.DayOfWeek.SATURDAY, java.time.DayOfWeek.SUNDAY), key = "horrortv.king", typed = true, seriesRefs = refs),
DayPart(6, 18, offAir = true),
DayPart(18, 21, HorrorTvEarly, key = "horrortv.early", typed = true, seriesRefs = refs),
DayPart(21, 23, HorrorTvStrong, key = "horrortv.strong", typed = true, seriesRefs = refs),
DayPart(23, 0, HorrorTvNightly, key = "horrortv.nightly", onTime = true, typed = true, seriesRefs = refs),
DayPart(0, 2, HorrorTvFeatured, key = "horrortv.featured", typed = true, seriesRefs = refs, seasonCap = HORROR_TV_FEATURED_AT_ONCE),
DayPart(2, 6, HorrorTvAnthology, key = "horrortv.anthology", typed = true, seriesRefs = refs))
}
@@ -37,7 +37,7 @@ private const val IDENT_SHORTEST_PROGRAMME_MS = 3 * 60_000L
private val IdentVideos = mapOf(ATLAS_NUMBER to R.raw.ident_113, SYNDICATE_NUMBER to R.raw.ident_114, PUNCHLINE_NUMBER to R.raw.ident_314, AMERICANA_NUMBER to R.raw.ident_111, OUTLAW_NUMBER to R.raw.ident_311, STORIES_NUMBER to R.raw.ident_112, SILVER_SCREEN_NUMBER to R.raw.ident_312, FRONTLINE_NUMBER to R.raw.ident_313, 108 to R.raw.ident_108, 109 to R.raw.ident_109, 110 to R.raw.ident_110, CHRISTMAS_NUMBER to R.raw.ident_310, 205 to R.raw.ident_205, 206 to R.raw.ident_206, 101 to R.raw.ident_101, 102 to R.raw.ident_102, 103 to R.raw.ident_103, 104 to R.raw.ident_104, 105 to R.raw.ident_105, 106 to R.raw.ident_106, 107 to R.raw.ident_107,
201 to R.raw.ident_201, 202 to R.raw.ident_202, 203 to R.raw.ident_203, 204 to R.raw.ident_204, 301 to R.raw.ident_301, 302 to R.raw.ident_302, 303 to R.raw.ident_303, 304 to R.raw.ident_304, 305 to R.raw.ident_305,
306 to R.raw.ident_306, 307 to R.raw.ident_307, 308 to R.raw.ident_308, 309 to R.raw.ident_309, 401 to R.raw.ident_401, 601 to R.raw.ident_601, 602 to R.raw.ident_602, 603 to R.raw.ident_603, 604 to R.raw.ident_604, 605 to R.raw.ident_605,
611 to R.raw.ident_611, 612 to R.raw.ident_612, 613 to R.raw.ident_613, WONDER_TV_NUMBER to R.raw.ident_615, HEROES_LIVE_NUMBER to R.raw.ident_115)
611 to R.raw.ident_611, 612 to R.raw.ident_612, 613 to R.raw.ident_613, WONDER_TV_NUMBER to R.raw.ident_615, HEROES_LIVE_NUMBER to R.raw.ident_115, HORROR_TV_NUMBER to R.raw.ident_116)
/** [atMs] is when the next programme starts, for a channel whose ident follows the time of day. */
/**
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.
Binary file not shown.
@@ -169,7 +169,7 @@ class ChannelPresetsTest {
// Kitchen, Home and Play joined on 6 November 2026.
// Americana, OUTLAW, Orbit Stories, Silver Screen and Frontline joined on 23 November 2026; ATLAS on 24 November;
// SYNDICATE and PUNCHLINE on 25 November.
assertEquals(46, SmartChannels.size)
assertEquals(47, SmartChannels.size)
}
@Test fun ringXKeepsItsWeeknightsAndFallsBackToTheVault() {
@@ -200,7 +200,7 @@ class ChannelPresetsTest {
@Test fun everySmartChannelIsBrandedAndNumberedAfterTheMove() {
SmartChannels.forEach { assertNotNull("${it.name} has no brand at ${it.number}", ChannelBrands.forNumber(it.number)) }
assertEquals(OldChannelNumbers.values.toSet() - DRIVE_IN_NUMBER + 101 + TOTS_NUMBER + setOf(108, 109, 110, 205, 206, CHRISTMAS_NUMBER, AMERICANA_NUMBER, OUTLAW_NUMBER, STORIES_NUMBER, SILVER_SCREEN_NUMBER, FRONTLINE_NUMBER, ATLAS_NUMBER, SYNDICATE_NUMBER, PUNCHLINE_NUMBER, WONDER_TV_NUMBER, HEROES_LIVE_NUMBER), SmartChannels.map { it.number }.toSet())
assertEquals(OldChannelNumbers.values.toSet() - DRIVE_IN_NUMBER + 101 + TOTS_NUMBER + setOf(108, 109, 110, 205, 206, CHRISTMAS_NUMBER, AMERICANA_NUMBER, OUTLAW_NUMBER, STORIES_NUMBER, SILVER_SCREEN_NUMBER, FRONTLINE_NUMBER, ATLAS_NUMBER, SYNDICATE_NUMBER, PUNCHLINE_NUMBER, WONDER_TV_NUMBER, HEROES_LIVE_NUMBER, HORROR_TV_NUMBER), SmartChannels.map { it.number }.toSet())
}
@Test fun kitchenHomeAndPlayAreBrandedInTheirBlocks() {
@@ -0,0 +1,87 @@
package tv.orbit.classic
import org.json.JSONObject
import org.junit.Assert.assertTrue
import org.junit.Assume.assumeTrue
import org.junit.Test
import java.io.File
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
/**
* Horror TV as built (HorrorTv.kt): its own blocks, off-air hours and season rotation, planned for five weeks against a TV
* snapshot's other plans from the audit's playable episodes, topped up daily as the box does. A second run loses the whole
* schedule every week (a restart that can't read it) and carries on from what aired. Env: SIM_SNAP, SIM_HORROR_BUILD
* (audit-20261201-horrortv-build/sim-build.json), SIM_OUT.
*/
class HorrorTvBuildSimulationTest {
@Test fun simulate() {
val dir = System.getenv("SIM_SNAP")?.let(::File); val src = System.getenv("SIM_HORROR_BUILD")?.let(::File)
assumeTrue(dir != null && dir.isDirectory && src != null && src.exists())
val out = File(System.getenv("SIM_OUT")!!).also { it.mkdirs() }
val zone = ZoneId.of("Europe/London")
val user = dir!!.listFiles()!!.first { it.name.startsWith("schedule-") }.let { JSONObject(it.readText()).getString("user") }
val store = ScheduleStore(dir)
val p = SmartChannels.first { it.number == HORROR_TV_NUMBER }
val parts = p.dayParts.map { it.copy() } // the same blocks, read in this zone
val pool = withinRuns(JSONObject(src!!.readText()).getJSONArray("series").let { a -> (0 until a.length()).map { a.getJSONObject(it) } }.map { o ->
val t = o.getString("title"); val id = o.getString("id"); val min = o.getInt("minutes")
val eps = o.getJSONArray("episodes").let { a -> (0 until a.length()).map { a.getJSONArray(it) } }
PoolSeries(id, t, eps.map { e -> val s = e.getInt(0); val n = e.getInt(1)
PoolEpisode("$id$s${"%03d".format(n)}", "9$id$s$n", EpisodeMark(s, n), "$t / S$s E$n", min * 60_000L) }, ref = HorrorTvSeriesRefs[t]?.firstOrNull { it.startsWith("tvdb.") }.orEmpty())
}, p.episodeRuns)
val others = (SmartChannels.map { it.number } - setOf(HORROR_TV_NUMBER) + DRIVE_IN_NUMBER).mapNotNull { n -> store.loadPlan(user, n)?.let { n to it } }.toMap()
val clash = clashesWithAirings(others.values.flatMap { airingsOf(it) })
val featured = parts.first { it.key == "horrortv.featured" }
val featuredKeys = featured.titles.map(::seriesKey).toSet()
fun strictness(title: String) = when (HorrorTvRatings[title]) { "TV-G" -> 0; "TV-PG" -> 1; "TV-14", "GB-12" -> 2; null -> 9; else -> 4 }
val report = StringBuilder("pool: ${pool.size} series (${pool.sumOf { it.episodes.size }} episodes)\n"); val checks = mutableListOf<Boolean>()
for ((label, startAt, loseEvery) in listOf(Triple("december", LocalDateTime.of(2026, 12, 1, 18, 0), 0), Triple("october", LocalDateTime.of(2027, 10, 1, 18, 0), 0),
Triple("december-restarts", LocalDateTime.of(2026, 12, 1, 18, 0), 7))) {
val now = startAt.atZone(zone).toInstant().toEpochMilli()
val all = LinkedHashMap<Long, ScheduleEntry>(); var plan: ChannelPlan? = null; var aired = ScheduleCursor(); var kept = true
for (d in 0 until 35) {
// A restart in the small hours, off the programmes' marks.
val lost = loseEvery > 0 && d > 0 && d % loseEvery == 0
val at = now + d * 86_400_000L + (if (lost) 9 * 3_600_000L + 7 * 60_000L else 0L)
plan?.let { aired = airedCursor(aired, it.entries, at) }
if (lost) all.keys.removeAll { it > at } // what hadn't aired is gone with the schedule
plan = topUpPlan(if (lost) null else plan, aired, pool, at, p.filmRestMs, p.finishTogether, parts, zone, avoid = clash, shuffle = p.shuffleEpisodes,
mixed = p::mixes, weightOf = p.tierWeights?.let { p::weightOf }, fileRestMs = p.fileRestMs, stories = p.storyGrouping, network = NoNetworkRest)!!
plan.entries.forEach { e -> all[e.startMs]?.let { if (it != e && !lost) kept = false } ?: run { all[e.startMs] = e } }
}
val entries = all.values.sortedBy { it.startMs }.filter { it.startMs < now + 35 * 86_400_000L }
fun local(ms: Long) = Instant.ofEpochMilli(ms).atZone(zone)
fun show(e: ScheduleEntry) = pool.first { it.id == e.seriesId }
File(out, "plan-116-$label.tsv").writeText("start\tminutes\ttitle\trating\tblock\n" + entries.joinToString("\n") {
"${local(it.startMs).toLocalDateTime()}\t${(it.endMs - it.startMs) / 60_000}\t${it.media.item.title}\t${HorrorTvRatings[show(it).title]}\t${presentationOf(it, parts, zone)}" })
val offAir = entries.count { local(it.startMs).hour in 6..17 }
val days = (0 until 34).map { startAt.toLocalDate().plusDays(it.toLong()) }
val lateStart = days.count { day -> entries.none { local(it.startMs).toLocalDate() == day && local(it.startMs).hour == 18 && local(it.startMs).minute == 0 } }
val matureEarly = entries.count { e -> local(e.startMs).hour in 18..22 && strictness(show(e).title) > 2 }
val noTwd = days.count { day -> entries.none { local(it.startMs).toLocalDate() == day && local(it.startMs).hour == 23 && show(it).title == "The Walking Dead" } }
val clashes = entries.count { clash(show(it), it.startMs, it.endMs) }
val order = entries.groupBy { it.seriesId }.count { (id, l) -> val eps = pool.first { it.id == id }.episodes.map { it.mark }
l.zipWithNext().any { (a, b) -> eps[(eps.indexOf(a.mark) + 1) % eps.size] != b.mark } }
// The rotation: never more than its cap part way through a season; a featured serial only in its own block.
val open = HashSet<String>(); var mostOpen = 0
entries.filter { seriesKey(show(it).title) in featuredKeys }.forEach { e -> open += e.seriesId; mostOpen = maxOf(mostOpen, open.size); if (!midSeason(show(e), e.mark)) open -= e.seriesId }
val featuredOutside = entries.count { seriesKey(show(it).title) in featuredKeys && local(it.startMs).hour !in 0..1 }
val films = entries.count { show(it).isFilm }
// Network rest is for films: Horror TV books none, so it never changes when another channel may show a film.
val restChanged = filmAiringsOf(ChannelPlan(entries, ScheduleCursor())).isNotEmpty()
val evening = entries.filter { local(it.startMs).hour in 18..20 }
val eveningRepeats = evening.groupBy { "${it.seriesId}/${it.mark}" }.values.count { it.size > 1 }
val seasonsDone = entries.filter { seriesKey(show(it).title) in featuredKeys && !midSeason(show(it), it.mark) }.size
val hours = entries.groupBy { show(it).title }.mapValues { (_, l) -> l.sumOf { it.endMs - it.startMs } / 3_600_000 }.toList().sortedByDescending { it.second }
report.append("$label: ${entries.size} programmes; booked off air $offAir; evenings not starting at 18:00 $lateStart; stricter than TV-14 before 23:00 $matureEarly; " +
"nights without The Walking Dead at 23:00 $noTwd; clashes $clashes; out of order $order; featured serials part way through a season at once (max) $mostOpen; " +
"featured outside midnight-02:00 $featuredOutside; featured seasons completed $seasonsDone; films $films; network rest changed $restChanged; bookings kept $kept; " +
"early-evening episodes ${evening.size} (repeated within five weeks: $eveningRepeats)\n top hours ${hours.take(10)}\n")
checks += listOf(offAir == 0, lateStart == 0, matureEarly == 0, noTwd == 0, clashes == 0, order == 0, mostOpen <= HORROR_TV_FEATURED_AT_ONCE, featuredOutside == 0, films == 0, !restChanged, kept)
}
File(out, "summary.txt").writeText(report.toString()); println(report)
assertTrue(report.toString(), checks.all { it })
}
}
@@ -0,0 +1,74 @@
package tv.orbit.classic
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import java.time.ZoneId
/** Horror TV (Paul, 1 December 2026): its hours, its blocks by rating, its exclusions, its season rotation, and its place on the box. */
class HorrorTvChannelTest {
private val p = SmartChannels.first { it.number == HORROR_TV_NUMBER }
private fun part(key: String) = p.dayParts.first { it.key == key }
/** Strictness of a rating as the audit judged it: 2 is TV-14 or UK 12, 3 and over is for adults. */
private fun strictness(rating: String) = when (rating) { "TV-G" -> 0; "TV-PG" -> 1; "TV-14", "GB-12" -> 2; "16", "ES-16" -> 3; else -> 4 }
@Test fun itsShowsAndWhatsLeftOut() {
assertEquals("Horror TV", p.name)
assertEquals(68, p.searches.size)
assertTrue(p.channelFilms.isEmpty())
assertTrue(p.finishTogether && p.exactTitles)
listOf("Children of the Stones", "Beasts", "Tales of the Unexpected").forEach { assertTrue(it, it in part("horrortv.early").titles) }
// Held for other channels' reviews, incomplete, or another channel's own.
listOf("The Ray Bradbury Theater", "Jamaica Inn", "Sapphire and Steel", "Sapphire & Steel", "Poirot", "Agatha Christie's Poirot", "Sherlock Holmes",
"Agatha Christie's Marple", "The Twilight Zone", "Stranger Things", "Grimm", "Haven", "Lost Girl", "Sleepy Hollow", "The Originals",
"The Walking Dead: Daryl Dixon", "Dark Shadows", "Into the Dark").forEach { assertFalse(it, it in p.searches) }
// Tales from the Crypt stays After Dark's: here only as an approved guest, never at the same moment ([clashesWithAirings]).
assertTrue("Tales from the Crypt" in part("horrortv.anthology").titles)
assertTrue(p.dayParts.filter { !it.offAir }.all { it.typed && it.seriesRefs.keys.containsAll(it.titles) })
assertTrue(HorrorTvSeriesRefs.values.all { refs -> refs.isNotEmpty() && refs.all { it.startsWith("tvdb.") || it.startsWith("imdb.tt") } })
}
@Test fun onAirFromSixUntilSixOffAirByDay() {
val off = p.dayParts.single { it.offAir }
assertEquals(6, off.fromHour); assertEquals(18, off.toHour)
assertTrue(off.titles.isEmpty())
val zone = ZoneId.systemDefault()
fun at(h: Int) = java.time.LocalDate.of(2026, 12, 2).atTime(h, 30).atZone(zone).toInstant().toEpochMilli()
(6..17).forEach { assertEquals("Back at 18:00", offAirUntil(HORROR_TV_NUMBER, at(it), zone)) }
((18..23) + (0..5)).forEach { assertEquals(null, offAirUntil(HORROR_TV_NUMBER, at(it), zone)) }
assertTrue(OffAirPictures.containsKey(HORROR_TV_NUMBER))
}
@Test fun eachShowSitsByItsStrictestRating() {
assertEquals(p.searches.toSet(), HorrorTvRatings.keys)
// Before 23:00, nothing stricter than TV-14 (UK 12); TV-MA (and 15, 16, 18) only from 23:00 to 06:00.
(part("horrortv.early").titles + part("horrortv.strong").titles).forEach { assertTrue(it, strictness(HorrorTvRatings.getValue(it)) <= 2) }
listOf("horrortv.nightly", "horrortv.featured", "horrortv.anthology", "horrortv.king").forEach { key ->
assertTrue(key, part(key).fromHour in listOf(23, 0, 2))
part(key).titles.forEach { assertTrue(it, strictness(HorrorTvRatings.getValue(it)) >= 3) }
}
// The strictest of a show's own rating and its episodes': Damien and Friday the 13th each have TV-MA episodes, Bates Motel 31.
listOf("Damien", "Friday the 13th: The Series", "Bates Motel", "Channel Zero", "Hammer House of Horror").forEach { assertEquals(it, "TV-MA", HorrorTvRatings[it]) }
assertEquals("TV-14", HorrorTvRatings["Tales of the Unexpected"])
assertEquals("GB-12", HorrorTvRatings["Beasts"])
}
@Test fun theFeaturedSerialsRunInASeasonRotation() {
val featured = part("horrortv.featured")
assertEquals(HORROR_TV_FEATURED_AT_ONCE, featured.seasonCap)
assertEquals(0, featured.fromHour); assertEquals(2, featured.toHour)
assertEquals(listOf("The Walking Dead"), part("horrortv.nightly").titles)
// A serial in the rotation is nowhere else on the channel, so only the rotation moves it on.
val elsewhere = p.dayParts.filter { it !== featured }.flatMap { it.titles }.toSet()
assertTrue(featured.titles.none { it in elsewhere })
assertTrue(p.dayParts.none { it.seasonCap > 0 && it !== featured })
}
@Test fun switchedOffUntilChosenAndBranded() {
val preset = ChannelPresets.single { it.number == HORROR_TV_NUMBER }
assertTrue(preset.smartOnly)
assertEquals("orbit-horror-tv", ChannelBrands.forNumber(HORROR_TV_NUMBER)?.presetId)
listOf("early", "strong", "nightly", "featured", "anthology", "king").forEach { assertTrue(it, "horrortv.$it" in BlockIdents) }
}
}
@@ -25,7 +25,8 @@ class PresentationTest {
// ATLAS's five dayparts and four film events on the 25th; then PUNCHLINE's five blocks and four events, and SYNDICATE's six
// blocks and four events; Wonder TV's five blocks on the 30th.
// Heroes Live's five blocks (30 November 2026).
assertEquals(39 + 9 + 10 + 5 + 5, keys.size)
// Horror TV's six blocks (1 December 2026).
assertEquals(39 + 9 + 10 + 5 + 5 + 6, keys.size)
assertEquals(emptySet<String>(), keys - BlockIdents.keys)
assertTrue(keys.all { PRESENTATION_KEY.matches(it) })
}
@@ -0,0 +1,138 @@
package tv.orbit.classic
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
/**
* The season rotation (Horror TV's featured serials, approved by Paul on 30 November 2026) and off-air hours (Horror TV by
* day, 1 December 2026): a few serials at a time, each handing over only once its season is over, carried across top-ups,
* restarts and a lost schedule; and nothing booked while a channel is off air.
*/
class SeasonRotationTest {
private val zone = ZoneId.systemDefault()
private val minute = 60_000L
private fun serial(name: String, vararg seasons: Int, minutes: Int = 50) = PoolSeries("s-$name", name,
seasons.withIndex().flatMap { (s, n) -> (1..n).map { e -> PoolEpisode("$name-${s + 1}-$e", "m", EpisodeMark(s + 1, e), "$name / S${s + 1} E$e", minutes * minute) } })
private fun at(day: Int, hour: Int) = LocalDate.of(2026, 12, 1).plusDays(day.toLong()).atTime(hour, 0).atZone(zone).toInstant().toEpochMilli()
private fun hour(ms: Long) = Instant.ofEpochMilli(ms).atZone(zone).hour
/** Walks the booked programmes: a series opens a season with its first episode there and closes it with its last. Returns the most open at once. */
private fun mostOpenAtOnce(entries: List<ScheduleEntry>, pool: List<PoolSeries>): Int {
val open = HashSet<String>(); var most = 0
for (e in entries) {
val show = pool.first { it.id == e.seriesId }
open += e.seriesId; most = maxOf(most, open.size)
if (!midSeason(show, e.mark)) open -= e.seriesId
}
return most
}
/** Every series' episodes in order, none skipped or repeated, going round to the start after its last. */
private fun inOrder(entries: List<ScheduleEntry>, pool: List<PoolSeries>) = entries.groupBy { it.seriesId }.all { (id, l) ->
val eps = pool.first { it.id == id }.episodes.map { it.mark }
l.zipWithNext().all { (a, b) -> eps[(eps.indexOf(a.mark) + 1) % eps.size] == b.mark }
}
@Test fun onlyAFewProgressAtOnceAndEachFinishesItsSeasonFirst() {
val pool = listOf(serial("A", 3, 3), serial("B", 4), serial("C", 2, 5), serial("D", 3), serial("E", 6))
val part = DayPart(0, 24, pool.map { it.title }, seasonCap = 2)
val plan = extendSchedule(pool, ScheduleCursor(), at(0, 0), at(3, 0), dayParts = listOf(part), zone = zone)
assertEquals(2, mostOpenAtOnce(plan.entries, pool))
assertTrue(inOrder(plan.entries, pool))
// Everyone gets a turn, in turn: the first two start, then each newcomer only as a season ends.
assertEquals(pool.map { it.id }.toSet(), plan.entries.map { it.seriesId }.toSet())
assertEquals(listOf("s-A", "s-B"), plan.entries.map { it.seriesId }.distinct().take(2))
assertTrue(plan.entries.first().why.contains("season rotation"))
}
@Test fun aSeriesThatFinishesItsSeasonGoesToTheBack() {
val pool = listOf(serial("A", 2, 2), serial("B", 5), serial("C", 5))
val part = DayPart(0, 24, pool.map { it.title }, seasonCap = 2)
val order = extendSchedule(pool, ScheduleCursor(), at(0, 0), at(0, 0) + 12 * 50 * minute, dayParts = listOf(part), zone = zone).entries.map { "${it.seriesId.removePrefix("s-")}${it.mark.season}${it.mark.episode}" }
// A's first season ends after two; C takes its place, and A's second season waits for a free place.
assertEquals(listOf("A11", "B11", "A12", "B12", "C11", "B13", "C12", "B14", "C13", "B15", "C14", "A21"), order)
}
@Test fun itCarriesAcrossTopUpsAsIfPlannedInOneGo() {
val pool = listOf(serial("A", 3, 4), serial("B", 6), serial("C", 2, 2, 2), serial("D", 5), serial("E", 4, 4))
val parts = listOf(DayPart(6, 18, offAir = true), DayPart(18, 0, pool.map { it.title }.take(2)), DayPart(0, 6, pool.map { it.title }, seasonCap = 2))
val once = extendSchedule(pool, ScheduleCursor(), at(0, 18), at(10, 18), dayParts = parts, zone = zone)
var plan: ChannelPlan? = null; var aired = ScheduleCursor()
val all = LinkedHashMap<Long, ScheduleEntry>(); var kept = true
for (d in 0 until 10) {
val now = at(d, 18)
plan?.let { aired = airedCursor(aired, it.entries, now) }
// A schedule ahead of a single day, so every top-up adds exactly what one plan would.
plan = topUpPlan(plan, aired, pool, now, dayParts = parts, zone = zone)!!
plan.entries.forEach { e -> all[e.startMs]?.let { if (it != e) kept = false } ?: run { all[e.startMs] = e } }
}
assertTrue("existing bookings never change", kept)
val topped = all.values.sortedBy { it.startMs }.filter { it.startMs < at(10, 18) }
assertEquals(once.entries.filter { it.startMs < at(7, 18) }, topped.filter { it.startMs < at(7, 18) })
}
@Test fun aRestartOrALostScheduleCarriesOnFromWhatAired() {
val pool = listOf(serial("A", 3, 4), serial("B", 6), serial("C", 2, 2, 2), serial("D", 5), serial("E", 4, 4))
val parts = listOf(DayPart(0, 24, pool.map { it.title }, seasonCap = 2))
var plan: ChannelPlan? = null; var aired = ScheduleCursor(); val airedEntries = mutableListOf<ScheduleEntry>()
for (step in 0 until 40) {
// Off the programmes' hour marks, as a restart is: the one on carries on and counts as aired.
val now = at(0, 0) + step * 187 * minute
plan?.let { p -> aired = airedCursor(aired, p.entries, now); airedEntries += p.entries.filter { it.startMs <= now && airedEntries.none { a -> a.startMs == it.startMs } } }
// Every fifth step the schedule is lost (a restart that couldn't read it): planning resumes from the aired place.
val existing = if (step % 5 == 4) null else plan
plan = topUpPlan(existing, aired, pool, now, dayParts = parts, zone = zone)!!
}
assertTrue(airedEntries.size > 30)
assertTrue("never more than the cap part way through a season", mostOpenAtOnce(airedEntries, pool) <= 2)
assertTrue("every series in order across the restarts", inOrder(airedEntries.sortedBy { it.startMs }, pool))
}
@Test fun aFinishedSeriesDoesNotHoldAPlace() {
// Shows finish together on Horror TV, so a series that has played everything waits; it mustn't take a place meanwhile.
val pool = listOf(serial("A", 2), serial("B", 6), serial("C", 6))
val part = DayPart(0, 24, pool.map { it.title }, seasonCap = 2)
val plan = extendSchedule(pool, ScheduleCursor(), at(0, 0), at(0, 0) + 14 * 50 * minute, finishTogether = true, dayParts = listOf(part), zone = zone)
val afterA = plan.entries.dropWhile { it.seriesId != "s-A" || it.mark.episode != 2 }.drop(1).take(4).map { it.seriesId }.toSet()
assertEquals(setOf("s-B", "s-C"), afterA)
assertTrue(inOrder(plan.entries, pool))
}
@Test fun nothingIsBookedOffAir() {
val pool = listOf(serial("A", 30, minutes = 47), serial("B", 30, minutes = 61))
val parts = listOf(DayPart(6, 18, offAir = true), DayPart(18, 6, pool.map { it.title }))
val plan = extendSchedule(pool, ScheduleCursor(), at(0, 18), at(4, 18), dayParts = parts, zone = zone)
assertTrue(plan.entries.none { hour(it.startMs) in 6..17 })
// Back on the hour every evening, and the programme on at 06:00 started before it.
(0 until 4).forEach { d -> assertTrue("day $d", plan.entries.any { it.startMs == at(d, 18) }) }
(1 until 4).forEach { d -> val last = plan.entries.last { it.startMs < at(d, 18) }; assertTrue(last.startMs < at(d, 6) && last.endMs >= at(d, 6)) }
assertTrue(inOrder(plan.entries, pool))
assertEquals(at(1, 18), offAirEnd(parts[0], at(1, 6) + 5 * minute, zone))
}
@Test fun offAirShowsFromTheEndOfTheLastProgramme() {
val pool = listOf(serial("A", 30, minutes = 47))
val parts = HorrorTvDayParts.filter { it.offAir } + DayPart(18, 6, listOf("A"))
val plan = extendSchedule(pool, ScheduleCursor(), at(0, 18), at(2, 18), dayParts = parts, zone = zone)
val loop = SampleChannel((1..2).map { ScheduledMedia(SampleItem("Loop $it", "Episode", 30L, "", "10$it", 30 * minute), "20$it", 30 * minute) }, "Horror TV", HORROR_TV_NUMBER)
val channel = ScheduledChannel(loop, plan)
val noon = channel.at(at(1, 12))
val lastBefore = plan.entries.last { it.startMs < at(1, 6) }
assertEquals(lastBefore.endMs, noon.startMs)
assertEquals(at(1, 18), noon.endMs)
assertEquals("Back at 18:00", offAirUntil(HORROR_TV_NUMBER, noon.startMs, zone))
assertNull(offAirUntil(HORROR_TV_NUMBER, at(1, 18), zone))
assertNull("the programme that started before 06:00 is on air", offAirUntil(HORROR_TV_NUMBER, lastBefore.startMs, zone))
assertNotNull(offAirUntil(HORROR_TV_NUMBER, at(1, 6), zone))
// Other channels are never off air.
assertNull(offAirUntil(HEROES_LIVE_NUMBER, at(1, 12), zone))
assertFalse(OffAirBlocks.keys.any { it != HORROR_TV_NUMBER })
}
}
@@ -21,7 +21,7 @@ class SpecialEventsTest {
assertEquals(expected.size, held.size)
// 55 before PUNCHLINE's 13 and SYNDICATE's 5 (Paul, 25 November 2026).
// Wonder TV's Featured film nights (30 November 2026): three, one for October, one for December, one for the rest.
assertEquals(55 + 13 + 5 + 3 + 1, held.size) // +1: Wonder TV's Friday and Sunday film nights (Togo)
assertEquals(55 + 13 + 5 + 3 + 1 + 1, held.size) // +1: Wonder TV's Friday and Sunday film nights (Togo); +1 Horror TV's King Weekend
}
@Test fun everyTakeoverIsThereExactlyOnce() {
@@ -38,7 +38,7 @@ class SpecialEventsTest {
}
@Test fun stageAAddsNothingAndEverythingIsApproved() {
assertEquals(55 + 13 + 5 + 3 + 1 + 4 + 18, all.size)
assertEquals(55 + 13 + 5 + 3 + 1 + 1 + 4 + 18, all.size)
assertTrue(all.all { it.status == SpecialStatus.Approved })
}
+22
View File
@@ -0,0 +1,22 @@
# Build 86 (version code 860): change log
Build 85 plus the changes below, on `horror-tv`. Horror TV is switched off until chosen in a profile's channels.
Nothing here moves an existing booking or changes another channel's home, ratings rules or dayparts.
## Horror TV (116): a new channel (Paul, 30 November and 1 December 2026)
- **On air 18:00 to 06:00, off air by day.** Nothing is booked from 06:00 to 18:00: the programme on at 06:00 finishes,
then the channel shows its "Horror TV returns at 6 PM" card, and the guide shows it off air. It's back on the hour at 18:00.
- **Blocks:** Early Evening Chills 18:00 (nothing above TV-14, with Children of the Stones, Beasts and Tales of the
Unexpected), Prime Time Terror 21:00 (TV-14), The Walking Dead nightly at 23:00 on the hour, Midnight Serials 00:00,
Tales from the Small Hours 02:00, and King Weekend on Saturday and Sunday nights from 02:00. TV-MA only from 23:00.
- **Ratings:** each show is placed by the strictest trustworthy rating of the series and all its episodes (so Damien,
Friday the 13th: The Series and Bates Motel count as TV-MA).
- **Season rotation (new, reusable):** Midnight Serials runs four serials at a time; a serial hands over only when its
season's last playable episode has been booked, then goes to the back. Worked out from each channel's saved place in its
series, so it carries across restarts, refreshes, top-ups and a lost schedule.
- **Homes kept:** Tales from the Crypt stays After Dark's (a guest here, never at the same moment). The Ray Bradbury
Theater waits for Paradox's review, Jamaica Inn for Orbit Showcase's, Sapphire & Steel until complete; mysteries stay Evidence's.
- **Look:** logo, guide badge, corner logo, colours, six block idents, a channel ident and the off-air card.
- Tests: SeasonRotationTest, HorrorTvChannelTest, HorrorTvBuildSimulationTest (three five-week runs, one losing its
schedule every week: nothing off air, nothing stricter than TV-14 before 23:00, no clashes, every series in order).