0.87.0: Orbit Three, Gold and Riot identities, fair block rotation
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m45s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m28s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-03 13:09:33 +00:00
co-authored by Claude Opus 5.5
parent fc2b8f18d3
commit 1d233c08bb
15 changed files with 191 additions and 39 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 106
versionName = "0.86.0-orbit-1-and-2"
versionCode = 107
versionName = "0.87.0-comedy-channels"
}
buildFeatures { compose = true }
compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 }
@@ -13,7 +13,7 @@ private val Weekend = setOf(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY)
private val Orbit1Family = listOf("The Fresh Prince of Bel-Air", "Full House", "Saved by the Bell", "Boy Meets World", "Sabrina the Teenage Witch", "Family Matters",
"Sister, Sister", "Malcolm in the Middle", "My Wife and Kids", "Young Sheldon", "Happy Days", "The Wonder Years", "Step by Step", "Kenan & Kel", "Smart Guy", "Lizzie McGuire")
private val Orbit1Evening = listOf("Frasier", "Cheers", "Everybody Loves Raymond", "The King of Queens", "The Big Bang Theory",
"Modern Family", "Two and a Half Men", "Home Improvement", "The Golden Girls", "3rd Rock from the Sun", "Roseanne")
"Modern Family", "Two and a Half Men", "Home Improvement", "The Golden Girls", "3rd Rock from the Sun", "Roseanne", "Friends", "How I Met Your Mother")
private val Orbit1Late = listOf("Frasier", "Cheers", "Everybody Loves Raymond", "The King of Queens", "The Big Bang Theory", "The Golden Girls", "Happy Days")
private val Orbit1British = listOf("My Family", "Outnumbered", "Not Going Out", "Miranda",
"Last of the Summer Wine", "Bread", "Goodnight Sweetheart", "Mrs. Brown's Boys", "Red Dwarf", "The Royle Family", "My Hero", "dinnerladies")
@@ -43,3 +43,54 @@ internal val Orbit2DayParts get() = listOf(
DayPart(17, 19, Orbit2Spooky, days = setOf(DayOfWeek.FRIDAY)),
DayPart(6, 15, Orbit2Daytime), DayPart(15, 18, Orbit2Teatime), DayPart(18, 21, Orbit2GameShows), DayPart(21, 0, Orbit2Panel), DayPart(0, 6, Orbit2RetroAction))
internal val Orbit2Mixed get() = Orbit2Shows.toSet()
/** Orbit Three, the cult comedy channel: alternative British comedy in the spirit of early BBC Three, and Scottish comedy at its heart. */
private val ThreeScottish = listOf("Still Game", "Limmy's Show!", "Burnistoun", "Chewin' the Fat", "Rab C. Nesbitt", "Gary: Tank Commander", "Scot Squad")
private val ThreeDaytime = listOf("Two Pints of Lager and a Packet of Crisps", "The Inbetweeners", "Bad Education", "Uncle", "Him & Her",
"Coupling", "Cuckoo", "Lunch Monkeys", "Man Like Mobeen", "People Just Do Nothing", "Black Books") + ThreeScottish
private val ThreeEvening = listOf("Gavin & Stacey", "The Mighty Boosh", "Spaced", "Fresh Meat", "Phoenix Nights",
"Being Human", "Green Wing", "This Country", "Extras", "The Office (UK)", "Toast of London", "Peep Show", "The IT Crowd", "Family Guy")
private val ThreeLate = listOf("Little Britain", "The League of Gentlemen", "Nighty Night", "Snuff Box", "Monkey Dust", "Psychoville", "Inside No. 9",
"Garth Marenghi's Darkplace", "Brass Eye", "The Day Today", "Nathan Barley", "Bo' Selecta!", "Stressed Eric")
private val ThreeOvernight = listOf("Two Pints of Lager and a Packet of Crisps", "The Inbetweeners", "Gavin & Stacey", "The Mighty Boosh", "Still Game", "Limmy's Show!", "Burnistoun", "Black Books")
internal val ThreeShows get() = (ThreeDaytime + ThreeEvening + ThreeLate).distinct()
internal val ThreeDayParts get() = listOf(
DayPart(21, 0, ThreeScottish, days = setOf(DayOfWeek.FRIDAY, DayOfWeek.SATURDAY)),
DayPart(6, 18, ThreeDaytime), DayPart(18, 22, ThreeEvening), DayPart(22, 2, ThreeLate), DayPart(2, 6, ThreeOvernight))
/** Story sitcoms in order, sketch and standalone comedy mixed. */
private val ThreeInOrder = setOf("Gavin & Stacey", "Spaced", "Fresh Meat", "Phoenix Nights", "Being Human", "Green Wing", "This Country", "Extras", "The Office (UK)",
"Him & Her", "The Inbetweeners", "Peep Show", "Psychoville", "Nathan Barley")
internal val ThreeMixed get() = (ThreeShows.toSet() - ThreeInOrder)
/** Orbit Gold, Britain's comedy treasures: the 60s to 90s classics, as UK Gold was. */
private val GoldDaytime = listOf("Keeping Up Appearances", "Open All Hours", "Are You Being Served?", "'Allo 'Allo!", "Hi-de-Hi!",
"The Good Life (1975)", "Butterflies", "As Time Goes By", "Waiting for God", "Some Mothers Do 'Ave 'Em", "Never the Twain", "Brush Strokes", "Still Open All Hours")
private val GoldEvening = listOf("Only Fools and Horses", "Fawlty Towers", "Dad's Army", "Father Ted", "The Vicar of Dibley", "Blackadder", "Porridge",
"One Foot in the Grave", "Yes Minister", "Yes, Prime Minister", "To the Manor Born", "Ever Decreasing Circles", "Just Good Friends")
private val GoldLate = listOf("Men Behaving Badly", "Red Dwarf", "Birds Of A Feather", "Rising Damp", "Steptoe and Son", "The Likely Lads", "Citizen Smith",
"Gimme Gimme Gimme", "The Royle Family", "Taskmaster", "8 Out of 10 Cats", "Peep Show", "The IT Crowd", "The Green Green Grass", "Ghosts")
private val GoldOvernight = listOf("Only Fools and Horses", "Dad's Army", "Father Ted", "Blackadder", "Porridge", "Keeping Up Appearances", "'Allo 'Allo!", "Hi-de-Hi!")
private val GoldSaturday = listOf("The Two Ronnies", "Minder", "Lovejoy")
internal val GoldShows get() = (GoldDaytime + GoldEvening + GoldLate + GoldSaturday).distinct()
internal val GoldDayParts get() = listOf(
DayPart(18, 22, listOf("Only Fools and Horses"), days = setOf(DayOfWeek.SUNDAY)),
DayPart(17, 19, GoldSaturday, days = setOf(DayOfWeek.SATURDAY)),
DayPart(6, 17, GoldDaytime), DayPart(17, 22, GoldEvening), DayPart(22, 2, GoldLate), DayPart(2, 6, GoldOvernight))
/** Only Fools and Horses runs in order, so Sunday Gold tells its story. Blackadder too. */
internal val GoldMixed get() = GoldShows.toSet() - setOf("Only Fools and Horses", "Blackadder")
/** Riot, loud, rude and animated: adult animation getting louder through the night. */
private val RiotDaytime = listOf("The Simpsons", "Futurama", "King of the Hill", "Bob's Burgers", "American Dad!",
"Daria", "Clone High", "The Critic", "Mission Hill", "Duckman", "The Cleveland Show", "Solar Opposites")
private val RiotLaughs = listOf("It's Always Sunny in Philadelphia", "Curb Your Enthusiasm", "Seinfeld", "Scrubs",
"Arrested Development", "Parks and Recreation", "The Office", "Friends", "How I Met Your Mother", "Trailer Park Boys", "Reno 911!", "Workaholics")
private val RiotAfterHours = listOf("South Park", "Family Guy", "Rick and Morty", "Beavis and Butt-Head", "BoJack Horseman",
"Archer (2009)", "Robot Chicken", "The Boondocks", "Big Mouth", "Celebrity Deathmatch", "Drawn Together", "Metalocalypse", "The Venture Bros.")
private val RiotGraveyard = listOf("Aqua Teen Hunger Force", "Sealab 2021", "Harvey Birdman, Attorney at Law", "Squidbillies", "Moral Orel", "Superjail!",
"Tim and Eric Awesome Show, Great Job!", "Dr. Katz, Professional Therapist", "The Ren & Stimpy Show")
private val RiotStunts = listOf("Jackass", "Dirty Sanchez", "Bo' Selecta!")
internal val RiotShows get() = (RiotDaytime + RiotLaughs + RiotAfterHours + RiotGraveyard + RiotStunts).distinct()
internal val RiotDayParts get() = listOf(
DayPart(22, 0, RiotStunts, days = setOf(DayOfWeek.SATURDAY)),
DayPart(6, 18, RiotDaytime), DayPart(18, 21, RiotLaughs), DayPart(21, 2, RiotAfterHours), DayPart(2, 6, RiotGraveyard))
internal val RiotMixed get() = RiotShows.toSet() - setOf("Arrested Development", "BoJack Horseman")
@@ -28,13 +28,9 @@ internal val ChannelPresets = listOf(
ChannelPreset(101, "Orbit 1", Orbit1Shows, smartOnly = true),
ChannelPreset(201, "Terra", listOf("Blue Planet", "Planet Earth", "Frozen Planet", "Life", "Our Planet")),
ChannelPreset(106, "Paradox", listOf("The X-Files", "Buffy the Vampire Slayer", "Supernatural", "Fringe", "Doctor Who (2005)")),
ChannelPreset(104, "Orbit Gold", listOf("Only Fools and Horses", "Father Ted", "Blackadder", "The Black Adder", "Fawlty Towers", "Ghosts", "The Good Life", "The Green Green Grass",
"The Vicar of Dibley", "Porridge", "Taskmaster", "8 Out of 10 Cats", "Dad's Army", "Yes Minister", "Keeping Up Appearances", "Open All Hours", "Rising Damp", "The Likely Lads", "Steptoe and Son", "Hi-de-Hi!", "'Allo 'Allo!",
"Are You Being Served?", "Birds of a Feather", "Men Behaving Badly", "The IT Crowd", "Peep Show"), smartOnly = true),
ChannelPreset(103, "Orbit Three", listOf("Still Game", "Limmy's Show", "The Mighty Boosh", "Two Pints of Lager and a Packet of Crisps", "Gary: Tank Commander", "Family Guy", "Gavin & Stacey", "Little Britain",
"The Inbetweeners", "Bad Education", "Burnistoun", "Rab C. Nesbitt", "Chewin' the Fat", "Phoenix Nights", "Him & Her", "Spaced", "Black Books", "Fresh Meat", "Uncle", "Scot Squad"), smartOnly = true),
ChannelPreset(105, "Riot", listOf("South Park", "The Simpsons", "It's Always Sunny in Philadelphia", "Trailer Park Boys", "Friends", "How I Met Your Mother", "Futurama", "American Dad!", "Bob's Burgers",
"King of the Hill", "Rick and Morty", "Beavis and Butt-Head", "Archer", "BoJack Horseman", "Seinfeld", "Scrubs", "The Office", "Arrested Development", "Parks and Recreation", "Curb Your Enthusiasm"), smartOnly = true),
ChannelPreset(104, "Orbit Gold", GoldShows, smartOnly = true),
ChannelPreset(103, "Orbit Three", ThreeShows, smartOnly = true),
ChannelPreset(105, "Riot", RiotShows, smartOnly = true),
ChannelPreset(602, "Heroes", listOf("Batman: The Animated Series", "Superman: The Animated Series", "Spider-Man: The Animated Series", "X-Men: The Animated Series", "Batman Beyond",
"Spider-Man Unlimited", "Justice League", "Justice League Unlimited", "Teen Titans", "Static Shock", "The Spectacular Spider-Man", "Young Justice",
"Batman: The Brave and the Bold", "Iron Man: Armored Adventures", "The Avengers: Earth's Mightiest Heroes", "The Batman", "Fantastic Four", "Silver Surfer",
@@ -78,10 +78,10 @@ internal val SmartChannels = listOf(
suggestionRules = SmartChannelRules[it.number].orEmpty(), dayParts = SmartChannelParts[it.number].orEmpty(), shuffleTitles = SmartChannelMixed[it.number].orEmpty()) }
/** Shows that play in a mixed order on channels whose identity is agreed. See ChannelIdentities.kt. */
private val SmartChannelMixed: Map<Int, Set<String>> get() = mapOf(101 to Orbit1Mixed, 102 to Orbit2Mixed)
private val SmartChannelMixed: Map<Int, Set<String>> get() = mapOf(101 to Orbit1Mixed, 102 to Orbit2Mixed, 103 to ThreeMixed, 104 to GoldMixed, 105 to RiotMixed)
/** Dark Files, from the programming bible: crime by day, mysteries early evening, the paranormal late. */
private val SmartChannelParts: Map<Int, List<DayPart>> get() = mapOf(101 to Orbit1DayParts, 102 to Orbit2DayParts, 204 to listOf(
private val SmartChannelParts: Map<Int, List<DayPart>> get() = mapOf(101 to Orbit1DayParts, 102 to Orbit2DayParts, 103 to ThreeDayParts, 104 to GoldDayParts, 105 to RiotDayParts, 204 to listOf(
DayPart(6, 18, DarkFilesCrime, group = "day"), DayPart(18, 21, DarkFilesMysteries, group = "evening"), DayPart(21, 6, DarkFilesParanormal, group = "late")),
// Ring X, from the bible: each weeknight's own show, and the whole vault the rest of the week.
401 to listOf(DayPart(0, 24, RingXMondayNight, days = setOf(java.time.DayOfWeek.MONDAY)), DayPart(0, 24, RingXImpact, days = setOf(java.time.DayOfWeek.TUESDAY)),
@@ -118,7 +118,9 @@ internal data class PoolSeries(val id: String, val title: String, val episodes:
/** Where a channel has got to: the last episode of each show, and whose turn was last. */
internal data class ScheduleCursor(val lastSeriesId: String? = null, val marks: Map<String, EpisodeMark> = emptyMap(),
/** When each film last started, for its rest period. */
val filmShown: Map<String, Long> = emptyMap())
val filmShown: Map<String, Long> = emptyMap(),
/** The last show to air in each block, so a block picks up its rotation where it left off rather than starting again each day. */
val blockLast: Map<String, String> = emptyMap())
internal data class ScheduleEntry(val seriesId: String, val mark: EpisodeMark, val media: ScheduledMedia, val startMs: Long,
/** Why the planner chose this, for diagnostics only. Empty for programmes planned before reasons were kept. */
@@ -248,7 +250,9 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
/** How many times the cursor's last show had already played in a row, so a run carries across a top-up. */
runBefore: Int = 0,
/** Off only in tests, to show that this rule is the one difference from planning before it existed. */
noThirdInARow: Boolean = true): ChannelPlan {
noThirdInARow: Boolean = true,
/** Off only in tests: each block keeps its own place in the rotation. */
blockRotation: Boolean = true): ChannelPlan {
require(pool.isNotEmpty() && pool.all { it.episodes.isNotEmpty() })
if (filmRestMs != null) return extendFilmSchedule(pool, cursor, fromMs, untilMs, filmRestMs, dayParts, zone, avoid)
val marks = cursor.marks.toMutableMap()
@@ -258,6 +262,7 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
val mixes = HashMap<String, List<PoolEpisode>>()
// How many times in a row the last show has played, counted from the start of this extension.
var run = if (cursor.lastSeriesId != null) runBefore else 0
val blockLast = cursor.blockLast.toMutableMap()
fun isMixed(show: PoolSeries) = shuffle || mixed(show)
fun running(show: PoolSeries) = if (isMixed(show)) mixes.getOrPut(show.id) { shuffledEpisodes(show) } else show.episodes
fun following(show: PoolSeries): PoolEpisode {
@@ -273,16 +278,18 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
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>()
val picked = turnOrder(pool, last).firstOrNull { show ->
// 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
val picked = turnOrder(pool, after).firstOrNull { show ->
when {
!allowed(show) -> { if (show in available) waiting += show.title; false }
avoid(show, start, start + following(show).durationMs) -> { elsewhere += show.title; false }
else -> true
}
}
val chosen = picked ?: nextInTurn(pool, last, allowed)
val chosen = picked ?: nextInTurn(pool, after, allowed)
// Never a third in a row while another show in the block is only waiting for the round to finish. That one starts its next round early.
val early = if (!noThirdInARow || !finishTogether || chosen.id != last || run < 2) null else turnOrder(pool, last).firstOrNull { show ->
val early = if (!noThirdInARow || !finishTogether || chosen.id != last || run < 2) null else turnOrder(pool, after).firstOrNull { show ->
show.id != chosen.id && show in available && marks[show.id] == running(show).last().mark && !avoid(show, start, start + running(show).first().durationMs)
}
if (early != null) marks.remove(early.id)
@@ -306,9 +313,10 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
marks[series.id] = episode.mark
run = if (series.id == last) run + 1 else 1
last = series.id
blockLast[block] = series.id
start += episode.durationMs
}
return ChannelPlan(entries, ScheduleCursor(last, marks))
return ChannelPlan(entries, ScheduleCursor(last, marks, blockLast = blockLast))
}
internal fun scheduledItem(seriesTitle: String, episode: PoolEpisode) = SampleItem(
@@ -324,7 +332,7 @@ internal fun airedCursor(base: ScheduleCursor, entries: List<ScheduleEntry>, now
marks[it.seriesId] = it.mark; last = it.seriesId
if (it.media.item.type == "Movie") shown[it.seriesId] = it.startMs
}
return ScheduleCursor(last, marks, shown)
return ScheduleCursor(last, marks, shown, base.blockLast)
}
/**
@@ -333,13 +341,13 @@ internal fun airedCursor(base: ScheduleCursor, entries: List<ScheduleEntry>, now
*/
internal fun topUpPlan(existing: ChannelPlan?, aired: ScheduleCursor, pool: List<PoolSeries>?, nowMs: Long, filmRestMs: Long? = null, finishTogether: Boolean = false,
dayParts: List<DayPart> = emptyList(), zone: java.time.ZoneId = java.time.ZoneId.systemDefault(), avoid: ProgrammeClash = { _, _, _ -> false }, shuffle: Boolean = false, noThirdInARow: Boolean = true,
mixed: (PoolSeries) -> Boolean = { false }): ChannelPlan? {
mixed: (PoolSeries) -> Boolean = { false }, blockRotation: Boolean = true): ChannelPlan? {
val kept = existing?.let { plan -> plan.copy(entries = plan.entries.dropWhile { it.endMs < nowMs - SCHEDULE_KEEP_PAST_MS }) }
if (kept != null && kept.endMs >= nowMs + SCHEDULE_TOP_UP_MS) return kept
if (pool.isNullOrEmpty()) return kept
val from = if (kept != null && kept.endMs > nowMs) kept.endMs else nowMs
val trailing = kept?.entries?.lastOrNull()?.let { tail -> kept.entries.asReversed().takeWhile { it.seriesId == tail.seriesId }.size } ?: 0
val added = extendSchedule(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, filmRestMs, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing, noThirdInARow)
val added = extendSchedule(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, filmRestMs, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing, noThirdInARow, blockRotation)
return ChannelPlan(kept?.entries.orEmpty() + added.entries, added.tail)
}
@@ -66,7 +66,7 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
connection.connectTimeout = 10_000
connection.readTimeout = request.readTimeoutMs ?: if (request.path == "/Sessions/Logout") 5_000 else 15_000
connection.setRequestProperty("Accept", "application/json")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.86.0\"")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.87.0\"")
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
if (request.method == "POST") {
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
@@ -76,12 +76,15 @@ internal class ScheduleStore(private val directory: File) {
private fun encodeCursor(cursor: ScheduleCursor) = JSONObject().put("last", cursor.lastSeriesId ?: JSONObject.NULL)
.put("marks", JSONObject().also { marks -> cursor.marks.forEach { (id, mark) -> marks.put(id, JSONArray().put(mark.season).put(mark.episode)) } })
.put("shown", JSONObject().also { shown -> cursor.filmShown.forEach { (id, at) -> shown.put(id, at) } })
.also { o -> if (cursor.blockLast.isNotEmpty()) o.put("blocks", JSONObject().also { blocks -> cursor.blockLast.forEach { (block, id) -> blocks.put(block, id) } }) }
private fun decodeCursor(o: JSONObject): ScheduleCursor {
val marks = o.getJSONObject("marks")
return ScheduleCursor(if (o.isNull("last")) null else validId(o.getString("last")),
marks.keys().asSequence().associate { id -> validId(id) to marks.getJSONArray(id).let { EpisodeMark(it.getInt(0), it.getInt(1)) } },
// Absent in files saved before film channels existed.
o.optJSONObject("shown")?.let { shown -> shown.keys().asSequence().associate { id -> validId(id) to shown.getLong(id) } }.orEmpty())
o.optJSONObject("shown")?.let { shown -> shown.keys().asSequence().associate { id -> validId(id) to shown.getLong(id) } }.orEmpty(),
// Absent in files saved before blocks kept their own place.
o.optJSONObject("blocks")?.let { blocks -> blocks.keys().asSequence().associate { block -> block.take(80) to validId(blocks.getString(block)) } }.orEmpty())
}
private fun validId(id: String) = id.also { require(EmbyClient.validId(it)) }
/** Reasons are diagnostics. A long one is cut rather than refused, so it can never cost a plan. */
@@ -33,7 +33,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
next.instanceFollowRedirects = false
next.connectTimeout = 10_000
next.readTimeout = 20_000
next.setRequestProperty("User-Agent", "OrbitTV/0.86.0")
next.setRequestProperty("User-Agent", "OrbitTV/0.87.0")
next.setRequestProperty("Accept-Encoding", "identity")
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {
@@ -33,17 +33,17 @@ class PlanBaselineTest {
}
private val day = 24 * hour
private fun plans(rule: Boolean = true) = linkedMapOf(
private fun plans(third: Boolean = true, blocks: Boolean = true) = linkedMapOf(
"turns" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day),
"finishTogether" to extendSchedule(shows, ScheduleCursor(), start, start + 4 * day, finishTogether = true, noThirdInARow = rule),
"dayParts" to extendSchedule(shows, ScheduleCursor(), start, start + 4 * day, finishTogether = true, dayParts = parts, zone = zone, noThirdInARow = rule),
"clash" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = rule),
"everythingClashes" to extendSchedule(listOf(show("a", 2, 7, 22)), ScheduleCursor(), start, start + day, avoid = avoid, noThirdInARow = rule),
"shuffle" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, shuffle = true, noThirdInARow = rule),
"finishTogether" to extendSchedule(shows, ScheduleCursor(), start, start + 4 * day, finishTogether = true, noThirdInARow = third, blockRotation = blocks),
"dayParts" to extendSchedule(shows, ScheduleCursor(), start, start + 4 * day, finishTogether = true, dayParts = parts, zone = zone, noThirdInARow = third, blockRotation = blocks),
"clash" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = third, blockRotation = blocks),
"everythingClashes" to extendSchedule(listOf(show("a", 2, 7, 22)), ScheduleCursor(), start, start + day, avoid = avoid, noThirdInARow = third, blockRotation = blocks),
"shuffle" to extendSchedule(shows, ScheduleCursor(), start, start + 3 * day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, shuffle = true, noThirdInARow = third, blockRotation = blocks),
"films" to extendSchedule(films, ScheduleCursor(), start, start + 5 * day, filmRestMs = 2 * day),
"filmsClash" to extendSchedule(films + listOf(PoolSeries("a", "Show a", listOf(PoolEpisode("a", "src-a", EpisodeMark(1, 1), "Show a", 90 * minute)))), ScheduleCursor(), start, start + 3 * day,
filmRestMs = day, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = rule),
"topUp" to topUpPlan(extendSchedule(shows, ScheduleCursor(), start, start + 2 * day), ScheduleCursor(), shows, start + day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = rule),
filmRestMs = day, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = third, blockRotation = blocks),
"topUp" to topUpPlan(extendSchedule(shows, ScheduleCursor(), start, start + 2 * day), ScheduleCursor(), shows, start + day, finishTogether = true, dayParts = parts, zone = zone, avoid = avoid, noThirdInARow = third, blockRotation = blocks),
)
@Test fun everyNewProgrammeSaysWhy() {
@@ -76,12 +76,18 @@ class PlanBaselineTest {
// Taken from 0.81.4, before reasons were recorded.
val expected = mapOf("turns" to "5cc4eee2cbfa29e6", "finishTogether" to "c357d2fae0d6a5df", "dayParts" to "764b7b7ac15a5b26", "clash" to "8d3c92c8c4beed8e",
"everythingClashes" to "9f38ee7d889140c5", "shuffle" to "cee9b485bc705af2", "films" to "2f4f2786280d4589", "filmsClash" to "7fe17b8f3746e164", "topUp" to "40ce5b5f8e0e8ed3")
// With the no-third-in-a-row rule off, planning is exactly as it was in 0.81.4.
assertEquals(expected, plans(rule = false).mapValues { fingerprint(it.value) })
// With the no-third-in-a-row rule and block rotation off, planning is exactly as it was in 0.81.4.
assertEquals(expected, plans(third = false, blocks = false).mapValues { fingerprint(it.value) })
}
@Test fun theRuleOnlyChangesPlansFromItsFirstEarlyRestart() {
val before = plans(rule = false); val after = plans(rule = true)
@Test fun theRulesOnlyChangeDayPartPlans() {
val before = plans(third = false, blocks = false); val after = plans()
// Plans without blocks are untouched by block rotation, and only change where a third in a row would have happened.
for (name in listOf("turns", "everythingClashes", "films")) assertEquals(name, before.getValue(name)!!.entries.map { it.seriesId to it.mark }, after.getValue(name)!!.entries.map { it.seriesId to it.mark })
}
@Test fun theNoThirdRuleOnlyChangesPlansFromItsFirstEarlyRestart() {
val before = plans(third = false); val after = plans()
for ((name, plan) in after) {
val old = before.getValue(name)!!.entries; val new = plan!!.entries
val firstEarly = new.indexOfFirst { "started its next round early" in it.why }
@@ -54,4 +54,20 @@ class RunLengthTest {
assertFalse(paradox.mixes(show("b", 1).copy(title = "Buffy the Vampire Slayer")))
assertFalse(paradox.mixes(show("s", 1).copy(title = "Supernatural")))
}
@Test fun aBlockCarriesOnItsRotationFromDayToDay() {
// Eight evening shows but only about four evening slots a day: each show must still get its turn across the week.
val zone = java.time.ZoneId.of("Europe/London")
val midnight = java.time.ZonedDateTime.of(2026, 11, 9, 0, 0, 0, 0, zone).toInstant().toEpochMilli()
val day = (1..3).map { show("day$it", 50) }; val evening = (1..8).map { show("eve$it", 50).copy(episodes = show("eve$it", 50).episodes.map { e -> e.copy(durationMs = 60 * minute) }) }
val parts = listOf(DayPart(20, 0, evening.map { it.title }), DayPart(0, 20, day.map { it.title }))
var plan = extendSchedule(day + evening, ScheduleCursor(), midnight, midnight + 60 * minute, finishTogether = true, dayParts = parts, zone = zone)
var all = plan.entries
while (plan.endMs < midnight + 7 * 24 * 60 * minute) {
plan = extendSchedule(day + evening, plan.tail, plan.endMs, plan.endMs + 60 * minute, finishTogether = true, dayParts = parts, zone = zone)
all = all + plan.entries
}
val aired = all.map { it.seriesId }.toSet()
assertTrue("every evening show airs: ${evening.map { it.id } - aired}", evening.all { it.id in aired })
}
}
+7
View File
@@ -0,0 +1,7 @@
# Orbit TV 0.87.0: Orbit Three, Gold and Riot identities, and fair block rotation
- Orbit Three, Orbit Gold and Riot now play the lists and day parts agreed with Paul on 3 November 2026 (docs/channels). Scottish comedy is in Orbit Three's daytime mix and in Scottish Comedy Night, Friday and Saturday 21:00 to 00:00. Gold keeps Sunday Gold. Riot keeps Riot Laughs and Saturday Stunt Night. Friends and How I Met Your Mother join Orbit 1's evening and keep their Riot appearances. "The Good Life" now matches the library's "The Good Life (1975)".
- Block rotation: each block now remembers its own place in its rotation, saved with the plan's cursor. Before, a block restarted from the same show each day, so in a week's replay from real episode counts 9 shows on Dark Files never aired, and the new configurations would have left 12 unseen on Orbit 2, 8 on Three, 7 on Gold and 4 on Riot. After: none on 101 to 106, 204, 601 and 614.
- Replay checks: block edges sensible (a block starts with the first programme after its hour), no episode twice in a week, nothing under 10 minutes. Fawlty Towers (12 episodes) airs about 7 times a week, down from 11.
- Committed plans are kept and phase in. A cursor saved by an older version simply has no block positions and starts them fresh.
- Unit tests: 330 passed, including the 9 plan fingerprints from 0.81.4 and a new day-to-day rotation test. Lint passed.
+2 -2
View File
@@ -14,10 +14,10 @@ Each document holds:
8. **New arrivals:** the kinds of future additions that belong here.
9. **Status:** agreed, proposed or built, with the date and the app version.
How weighting works today: within a block, every show gets an equal turn. A show's share comes from how many blocks it appears in, so core shows sit in two blocks and supporting shows in one. There are no percentages in the scheduler.
How weighting works today: within a block, every show gets an equal turn, and from 0.87.0 each block remembers its own place in the rotation, so a block with more shows than slots still reaches every show over the week. A show's share comes from how many blocks it appears in, so core shows sit in two blocks and supporting shows in one. There are no percentages in the scheduler.
Film channels follow their own model (genre, rest period, first Orbit screenings), not the 70/20/10 guide.
Documents so far: [Paradox](paradox.md) (agreed), [Orbit 1](orbit-1.md) (agreed), [Orbit 2](orbit-2.md) (agreed).
Documents so far: [Paradox](paradox.md) (agreed), [Orbit 1](orbit-1.md) (agreed), [Orbit 2](orbit-2.md) (agreed), [Orbit Three](orbit-three.md), [Orbit Gold](orbit-gold.md) and [Riot](riot.md) (agreed in principle).
Historical inspiration: real UK channels (Sky One, Trouble, Challenge TV, BBC Two teatime, Bravo, early BBC Three, UK Gold, Cartoon Network UK, Toonami UK, Fox Kids UK, Boomerang) inform the feel. Documents separate verified historical programming, with sources, from shows that only fit the style. Orbit takes the feeling, not a frozen copy of an old schedule.
+1 -1
View File
@@ -8,7 +8,7 @@
**Paul's favourites:** The Fresh Prince of Bel-Air, Saved by the Bell, Boy Meets World, Sabrina, Frasier, Cheers, The Wonder Years and the Sunday dramas.
**Supporting:** Sister, Sister, Malcolm in the Middle, My Wife and Kids, Young Sheldon, Happy Days, The Wonder Years, Modern Family, Two and a Half Men, Home Improvement, The Golden Girls, Last of the Summer Wine, Bread, Goodnight Sweetheart, Mrs. Brown's Boys. In the library and proposed: Step by Step, Kenan & Kel, Smart Guy, Lizzie McGuire, 3rd Rock from the Sun, Roseanne, The Royle Family, My Hero, dinnerladies.
**Supporting:** Sister, Sister, Malcolm in the Middle, My Wife and Kids, Young Sheldon, Happy Days, The Wonder Years, Modern Family, Two and a Half Men, Home Improvement, The Golden Girls, Friends, How I Met Your Mother (preferred home here, also on Riot Laughs), Last of the Summer Wine, Bread, Goodnight Sweetheart, Mrs. Brown's Boys. In the library and proposed: Step by Step, Kenan & Kel, Smart Guy, Lizzie McGuire, 3rd Rock from the Sun, Roseanne, The Royle Family, My Hero, dinnerladies.
**Surprises:** occasional surprises and light family entertainment keep the flagship from being only sitcoms. A Sunday comfort-drama slot, 18:00 to 20:00: Doc Martin, Heartbeat, Ballykissangel, Little House on the Prairie, The Waltons.
+23
View File
@@ -0,0 +1,23 @@
# Orbit Gold (104): Britain's comedy treasures
**Status:** agreed in principle with Paul 3 November 2026. Configured in 0.87.0, not yet installed.
**Identity:** the classic British comedy institution: 60s to 90s sitcoms everyone knows, warm, timeless and familiar. **Tagline idea:** "The good old days, every day."
**History, verified:** UKTV has described Gold as "well entrenched in the UK's psyche as the home of national treasure comedies", naming Only Fools and Horses and The Vicar of Dibley. Source: Wikipedia, U&Gold, read 3 November 2026. UK Gold's exact 1990s schedules aren't verified, so the blocks borrow the feeling, not a real schedule.
**Core:** Only Fools and Horses, Fawlty Towers, Dad's Army, Father Ted, The Vicar of Dibley, Keeping Up Appearances, Open All Hours, Porridge, Blackadder, One Foot in the Grave.
**Supporting:** Are You Being Served?, 'Allo 'Allo!, Hi-de-Hi!, The Good Life, Butterflies, As Time Goes By, Waiting for God, Some Mothers Do 'Ave 'Em, Never the Twain, Brush Strokes, Still Open All Hours, Yes Minister, Yes, Prime Minister, To the Manor Born, Ever Decreasing Circles, Just Good Friends, Men Behaving Badly, Red Dwarf, Birds Of A Feather, Rising Damp, Steptoe and Son, The Likely Lads, Citizen Smith, Gimme Gimme Gimme, The Royle Family.
**Surprises:** Saturday 17:00 to 19:00: The Two Ronnies, Minder, Lovejoy.
**Time of day:** 06:00 to 17:00 gentle classics. 17:00 to 22:00 the big ones. 22:00 to 02:00 late laughs. 02:00 to 06:00 repeats. **Sunday Gold**, Sunday 18:00 to 22:00: Only Fools and Horses in order.
**Order:** mixed, except Only Fools and Horses and Blackadder in order.
**Crossover:** preferred home of Red Dwarf. Taskmaster and 8 Out of 10 Cats have Orbit 2 as their preferred home, and Peep Show and The IT Crowd have Orbit Three; Gold keeps all four, outside its core. Orbit 1 is the preferred home of Last of the Summer Wine, Bread and Goodnight Sweetheart.
**To measure after phase-in:** repeats of short series. In a week's replay from real episode counts, Fawlty Towers (12 episodes) airs about 7 times, down from 11, with no episode twice in the week.
**New arrivals:** British sitcoms and sketch comedy from the 60s to the 90s, and later revivals of them.
+21
View File
@@ -0,0 +1,21 @@
# Orbit Three (103): the cult comedy channel
**Status:** agreed in principle with Paul 3 November 2026. Configured in 0.87.0 (ChannelIdentities.kt), not yet installed.
**Identity:** alternative British comedy for grown-ups who never quite grew up: cult sitcoms, sketch shows, the strange and the experimental, in the spirit of early BBC Three. Scottish comedy is a defining part of the channel, as Paul intended from the start. **Tagline idea:** "Comedy, but weirder."
**History, verified:** BBC Choice (1998 to 2003) aired Stressed Eric and gave Robot Wars episodes their first airing ahead of the main BBC channels. BBC Three replaced it and built itself on comedy and comedy-drama: Gavin & Stacey began there in May 2007, Being Human became one of its successes, and Family Guy and American Dad! were notable imports. Source: Wikipedia, BBC Choice and BBC Three (former), read 3 November 2026. Many supporting shows began on Channel 4 or BBC Two instead, so they're the same spirit, not BBC Three history.
**Core:** Still Game, Limmy's Show!, Burnistoun, Chewin' the Fat, Rab C. Nesbitt (Scottish). Gavin & Stacey, The Mighty Boosh, Little Britain, The Inbetweeners, Two Pints of Lager and a Packet of Crisps, Spaced, Phoenix Nights.
**Supporting:** Gary: Tank Commander, Scot Squad, Him & Her, Bad Education, Uncle, Fresh Meat, Black Books, Coupling, Cuckoo, Lunch Monkeys, Man Like Mobeen, People Just Do Nothing, Being Human, Green Wing, This Country, Extras, The Office (UK), Toast of London, Peep Show, The IT Crowd.
**Surprises:** The League of Gentlemen, Nighty Night, Snuff Box, Monkey Dust, Psychoville, Inside No. 9, Garth Marenghi's Darkplace, Brass Eye, The Day Today, Nathan Barley, Bo' Selecta!, Stressed Eric, Family Guy.
**Time of day:** 06:00 to 18:00 daytime, with the Scottish shows in the regular mix. 18:00 to 22:00 evening story comedy. 22:00 to 02:00 cult and sketch. 02:00 to 06:00 repeats. **Scottish Comedy Night**, Friday and Saturday 21:00 to 00:00.
**Order:** story sitcoms in order (Gavin & Stacey, Spaced, Fresh Meat, Phoenix Nights, Being Human, Green Wing, This Country, Extras, The Office, Him & Her, The Inbetweeners, Peep Show, Psychoville, Nathan Barley). Sketch and standalone comedy mixed.
**Crossover:** preferred home of Peep Show and The IT Crowd, which Orbit Gold keeps. Riot is the preferred home of Family Guy and Bo' Selecta!, kept here too.
**New arrivals:** British comedy from about 1998 onwards that's cult, alternative, sketch-based or for younger adults, and Scottish comedy.
+21
View File
@@ -0,0 +1,21 @@
# Riot (105): loud, rude and animated
**Status:** agreed in principle with Paul 3 November 2026. Configured in 0.87.0, not yet installed. Its look stays 2D on purpose.
**Identity:** the rebel channel: bold adult animation, irreverent comedy and attitude, louder as the night goes on. **Tagline idea:** "Turn it up."
**History, verified:** Trouble launched on 3 February 1997 from the teenage part of The Children's Channel, ran from noon to 8pm sharing its channel with Bravo, and leaned on popular sitcoms more than cartoons. Source: Wikipedia, Trouble (TV channel), read 3 November 2026. MTV and Comedy Central UK inspiration is style only, not yet sourced.
**Core:** South Park, The Simpsons, Family Guy, Futurama, Beavis and Butt-Head, Rick and Morty, American Dad!, King of the Hill, It's Always Sunny in Philadelphia, BoJack Horseman.
**Supporting:** Bob's Burgers, Daria, Clone High, The Critic, Mission Hill, Duckman, The Cleveland Show, Solar Opposites, Archer, Robot Chicken, The Boondocks, Big Mouth, Celebrity Deathmatch, Drawn Together, Metalocalypse, The Venture Bros., Curb Your Enthusiasm, Seinfeld, Scrubs, Arrested Development, Parks and Recreation, The Office, Trailer Park Boys, Reno 911!, Workaholics.
**Surprises:** the Graveyard block (Aqua Teen Hunger Force, Sealab 2021, Harvey Birdman, Squidbillies, Moral Orel, Superjail!, Tim and Eric, Dr. Katz, The Ren & Stimpy Show) and Saturday Stunt Night.
**Time of day:** 06:00 to 18:00 cartoons for grown-ups. **Riot Laughs**, 18:00 to 21:00. **After Hours**, 21:00 to 02:00. **Graveyard**, 02:00 to 06:00. **Stunt Night**, Saturday 22:00 to 00:00: Jackass, Dirty Sanchez, Bo' Selecta!.
**Order:** mixed, except Arrested Development and BoJack Horseman in order.
**Crossover:** preferred home of Family Guy, American Dad!, Futurama and Bo' Selecta!. Friends and How I Met Your Mother have Orbit 1 as their preferred home and keep their Riot Laughs appearances.
**New arrivals:** adult animation, irreverent and cringe comedy, and stunt and prank shows.