0.99.3: adaptive film rest for After Dark and Premiere (events keep 7 days)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,8 @@ android {
|
||||
applicationId = "tv.orbit.classic"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 132
|
||||
versionName = "0.99.2-clash-checks"
|
||||
versionCode = 133
|
||||
versionName = "0.99.3-adaptive-film-rest"
|
||||
}
|
||||
buildFeatures { compose = true }
|
||||
compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 }
|
||||
|
||||
@@ -43,7 +43,9 @@ internal data class ChannelProgramming(val number: Int, val name: String, val se
|
||||
* Editorially weighted rotation (see [extendWeighted]), switched on per channel: each show's weight from its tier in
|
||||
* the channel's brief. Null keeps equal turns. Only Orbit Three has it (approved 4 November 2026).
|
||||
*/
|
||||
val tierWeights: Map<String, Double>? = null) {
|
||||
val tierWeights: Map<String, Double>? = null,
|
||||
/** A film channel's everyday blocks rest each film for a share of how long their own films take to play through ([adaptiveRestMs]). */
|
||||
val adaptiveFilmRest: Boolean = false) {
|
||||
/** A show's weight here, by its tier; a show the brief doesn't name counts as supporting. */
|
||||
fun weightOf(show: PoolSeries) = tierWeights?.get(seriesKey(show.title)) ?: TIER_SUPPORTING
|
||||
/** Whether a show plays its episodes in a mixed order here. */
|
||||
@@ -76,7 +78,7 @@ private val AfterDarkFilms = listOf("The Thing (1982)", "The Evil Dead (1983)",
|
||||
"Army of Darkness", "House (1977)", "The Holy Mountain", "Repo! The Genetic Opera")
|
||||
|
||||
internal val SmartChannels = listOf(
|
||||
ChannelProgramming(AFTER_DARK_NUMBER, "After Dark", AfterDarkFilms, seriesCount = AfterDarkFilms.size, filmSeries = listOf(LAST_DRIVE_IN), filmRestMs = 7 * 24 * 60 * 60_000L,
|
||||
ChannelProgramming(AFTER_DARK_NUMBER, "After Dark", AfterDarkFilms, seriesCount = AfterDarkFilms.size, filmSeries = listOf(LAST_DRIVE_IN), filmRestMs = 7 * 24 * 60 * 60_000L, adaptiveFilmRest = true,
|
||||
dayParts = AfterDarkEvents + listOf(DayPart(21, 5), DayPart(5, 21, listOf("The 'Burbs", "'Til Death Do Us Part (2017)", "Tremors (1990)", "The Lost Boys (1987)", "Fright Night (1985)", "Poltergeist (1982)", "Scream (1996)",
|
||||
"Escape from New York", "They Live", "Repo Man", "Donnie Darko", "From Dusk Till Dawn", "Creepshow", "Near Dark", "Halloween (1978)", "The Fog (1980)", "Blue Velvet",
|
||||
"The Wicker Man (1973)", "An American Werewolf in London", "Prince of Darkness"), group = "day")),
|
||||
@@ -101,7 +103,10 @@ internal val SmartChannels = listOf(
|
||||
ChannelPresets.filter { it.smartOnly }.map { ChannelProgramming(it.number, it.name, it.searches, seriesCount = if (it.films) it.searches.size else 60, finishTogether = !it.films, exactTitles = true,
|
||||
filmRestMs = if (it.films) 7 * 24 * 60 * 60_000L else null,
|
||||
suggestionRules = SmartChannelRules[it.number].orEmpty(), dayParts = SmartChannelParts[it.number].orEmpty(), shuffleTitles = SmartChannelMixed[it.number].orEmpty(),
|
||||
channelFilms = if (it.number == 401) PpvSunday else emptyList(), tierWeights = SmartChannelTiers[it.number]) }
|
||||
channelFilms = if (it.number == 401) PpvSunday else emptyList(), tierWeights = SmartChannelTiers[it.number], adaptiveFilmRest = it.number in AdaptiveFilmRestChannels) }
|
||||
|
||||
/** Film channels whose rest adapts to their pools: Premiere, whose pool runs well past a week (After Dark is set above). Proposed 4 November 2026. */
|
||||
private val AdaptiveFilmRestChannels get() = setOf(301)
|
||||
|
||||
/** Editorially weighted rotation, per channel, once its tiers are approved: Orbit Three (0.97.0), then Odyssey, Wild, Orbit X and ToonZ (0.98.0). */
|
||||
private val SmartChannelTiers: Map<Int, Map<String, Double>> get() = mapOf(103 to ThreeTiers, 202 to OdysseyTiers, 203 to WildTiers, 603 to OrbitXTiers, 605 to ToonZTiers)
|
||||
@@ -265,7 +270,8 @@ internal fun chooseFilm(pool: List<PoolSeries>, shown: Map<String, Long>, startM
|
||||
|
||||
/** Films by their rest period, back to back from [fromMs] until [untilMs] is covered. */
|
||||
internal fun extendFilmSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, fromMs: Long, untilMs: Long, restMs: Long,
|
||||
dayParts: List<DayPart> = emptyList(), zone: java.time.ZoneId = java.time.ZoneId.systemDefault(), avoid: ProgrammeClash = { _, _, _ -> false }): ChannelPlan {
|
||||
dayParts: List<DayPart> = emptyList(), zone: java.time.ZoneId = java.time.ZoneId.systemDefault(), avoid: ProgrammeClash = { _, _, _ -> false },
|
||||
adaptiveRest: Boolean = false): ChannelPlan {
|
||||
val shown = cursor.filmShown.toMutableMap()
|
||||
val entries = mutableListOf<ScheduleEntry>()
|
||||
var last = cursor.lastSeriesId
|
||||
@@ -286,7 +292,9 @@ internal fun extendFilmSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor,
|
||||
continue
|
||||
}
|
||||
val films = available.filter { it.isFilm }.ifEmpty { pool.filter { it.isFilm } }.ifEmpty { available }
|
||||
val (film, why) = chooseFilm(films, shown, start, restMs, avoid)
|
||||
// Events keep the channel's rest; everyday blocks, when adaptive, rest by how long their own films last.
|
||||
val rest = if (adaptiveRest && part?.days.isNullOrEmpty()) adaptiveRestMs(films, part, restMs) else restMs
|
||||
val (film, why) = chooseFilm(films, shown, start, rest, avoid)
|
||||
val copy = film.episodes.first()
|
||||
val item = SampleItem(film.title, "Movie", copy.durationMs / 60_000, "", copy.id, copy.durationMs)
|
||||
// Only a programme actually drawn from the event's own titles carries its presentation.
|
||||
@@ -298,6 +306,25 @@ internal fun extendFilmSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor,
|
||||
return ChannelPlan(entries, ScheduleCursor(last, marks, shown))
|
||||
}
|
||||
|
||||
/** Adaptive film rest: a small block rests films this share of its play-through time; a big one up to [ADAPTIVE_REST_LONG_SHARE], never under the channel's rest. */
|
||||
internal const val ADAPTIVE_REST_SHORT_SHARE = 0.9
|
||||
internal const val ADAPTIVE_REST_LONG_SHARE = 0.8
|
||||
internal const val ADAPTIVE_REST_FLOOR_MS = 2 * 24 * 60 * 60_000L
|
||||
internal const val ADAPTIVE_REST_CEILING_MS = 14 * 24 * 60 * 60_000L
|
||||
|
||||
/**
|
||||
* How long a film rests in an everyday block, from how long the block's films take to play through back to back in its
|
||||
* daily hours. When that's too short for the channel's own rest ([restMs]), [ADAPTIVE_REST_SHORT_SHARE] of it, so each
|
||||
* pick comes from a real shortlist instead of the same longest-waiting order every cycle. When it's longer, up to
|
||||
* [ADAPTIVE_REST_LONG_SHARE] of it but never less than [restMs], so a big pool airs more of itself.
|
||||
*/
|
||||
internal fun adaptiveRestMs(films: List<PoolSeries>, part: DayPart?, restMs: Long): Long {
|
||||
val hours = part?.let { ((it.toHour - it.fromHour + 24) % 24).let { h -> if (h == 0) 24 else h } } ?: 24
|
||||
val cycle = films.sumOf { it.episodes.first().durationMs }.toDouble() * 24 / hours
|
||||
val rest = if (cycle * ADAPTIVE_REST_SHORT_SHARE < restMs) cycle * ADAPTIVE_REST_SHORT_SHARE else maxOf(restMs.toDouble(), cycle * ADAPTIVE_REST_LONG_SHARE)
|
||||
return rest.toLong().coerceIn(ADAPTIVE_REST_FLOOR_MS, ADAPTIVE_REST_CEILING_MS)
|
||||
}
|
||||
|
||||
/** A one-a-night event counts as having had its turn for this long after a programme from it starts. */
|
||||
private const val ONCE_A_NIGHT_MS = 12 * 60 * 60_000L
|
||||
/** How far ahead an on-time appointment is looked for, and how late after its hour it may start. */
|
||||
@@ -438,9 +465,11 @@ internal fun extendSchedule(pool: List<PoolSeries>, cursor: ScheduleCursor, from
|
||||
/** Off only in tests, to show that this rule is the one difference from planning before it existed. */
|
||||
noThirdInARow: Boolean = true,
|
||||
/** Off only in tests: each block keeps its own place in the rotation. */
|
||||
blockRotation: Boolean = true): ChannelPlan {
|
||||
blockRotation: Boolean = true,
|
||||
/** Film channels only: see [ChannelProgramming.adaptiveFilmRest]. */
|
||||
adaptiveRest: Boolean = false): ChannelPlan {
|
||||
require(pool.isNotEmpty() && pool.all { it.episodes.isNotEmpty() })
|
||||
if (filmRestMs != null) return extendFilmSchedule(pool, cursor, fromMs, untilMs, filmRestMs, dayParts, zone, avoid)
|
||||
if (filmRestMs != null) return extendFilmSchedule(pool, cursor, fromMs, untilMs, filmRestMs, dayParts, zone, avoid, adaptiveRest)
|
||||
val marks = cursor.marks.toMutableMap()
|
||||
val entries = mutableListOf<ScheduleEntry>()
|
||||
var last = cursor.lastSeriesId
|
||||
@@ -570,7 +599,9 @@ internal fun topUpPlan(existing: ChannelPlan?, aired: ScheduleCursor, pool: List
|
||||
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 }, blockRotation: Boolean = true,
|
||||
/** Set for a channel with editorially weighted rotation ([ChannelProgramming.weightOf]); null keeps equal turns. */
|
||||
weightOf: ((PoolSeries) -> Double)? = null): ChannelPlan? {
|
||||
weightOf: ((PoolSeries) -> Double)? = null,
|
||||
/** Film channels only: see [ChannelProgramming.adaptiveFilmRest]. */
|
||||
adaptiveRest: Boolean = false): 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
|
||||
@@ -579,7 +610,7 @@ internal fun topUpPlan(existing: ChannelPlan?, aired: ScheduleCursor, pool: List
|
||||
val added = if (weightOf != null && filmRestMs == null) {
|
||||
val recent = kept?.entries.orEmpty().filter { it.startMs >= from - SAME_FILE_MS }.associate { it.media.item.id to it.startMs }
|
||||
extendByBlock(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, weightOf, dayParts, zone, avoid, shuffle, mixed, finishTogether, recent, trailing)
|
||||
} else extendSchedule(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, filmRestMs, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing, noThirdInARow, blockRotation)
|
||||
} else extendSchedule(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, filmRestMs, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing, noThirdInARow, blockRotation, adaptiveRest)
|
||||
return ChannelPlan(kept?.entries.orEmpty() + added.entries, added.tail)
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ internal class ChannelScheduler(private val store: ScheduleStore, private val cl
|
||||
val others by lazy { clashesWith((SmartChannels.map { it.number }.filter { it != number } + DRIVE_IN_NUMBER).mapNotNull { store.loadPlan(userId, it) }) }
|
||||
val plan = topUpPlan(existing, base, pool?.series?.let { withoutFailed(it, store.loadFailed(userId)) }, now, programming.filmRestMs, programming.finishTogether, programming.dayParts,
|
||||
avoid = { show, startMs, endMs -> others(show, startMs, endMs) }, shuffle = programming.shuffleEpisodes, mixed = programming::mixes,
|
||||
weightOf = programming.tierWeights?.let { programming::weightOf }) ?: throw EmbyCheckException("${programming.name} has no episodes to schedule.")
|
||||
weightOf = programming.tierWeights?.let { programming::weightOf }, adaptiveRest = programming.adaptiveFilmRest) ?: throw EmbyCheckException("${programming.name} has no episodes to schedule.")
|
||||
if (plan !== existing) store.savePlan(userId, number, plan)
|
||||
store.saveProgress(userId, number, ScheduleStore.SavedProgress(progress?.enabled ?: true, airedCursor(base, plan.entries, now)))
|
||||
session.rememberScheduledItems(plan.entries.map { it.media.item })
|
||||
|
||||
@@ -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.99.2\"")
|
||||
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.99.3\"")
|
||||
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
|
||||
if (request.method == "POST") {
|
||||
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
|
||||
|
||||
@@ -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.99.2")
|
||||
next.setRequestProperty("User-Agent", "OrbitTV/0.99.3")
|
||||
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()) {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class AdaptiveFilmRestTest {
|
||||
private val day = 24 * 60 * 60_000L
|
||||
private val zone = java.time.ZoneOffset.UTC
|
||||
private val start = java.time.LocalDate.of(2026, 11, 10).atStartOfDay(zone).toInstant().toEpochMilli()
|
||||
private fun films(n: Int, minutes: Int = 100) = (1..n).map { PoolSeries("f$it", "Film $it", listOf(PoolEpisode("f$it", "src", EpisodeMark(1, 1), "Film $it", minutes * 60_000L))) }
|
||||
|
||||
@Test fun theRestFollowsHowLongTheBlocksFilmsLast() {
|
||||
// 72 films of 100 minutes over 24 hours: 5 days back to back, too short for 7 days, so 90% of it.
|
||||
assertEquals((5 * day * 0.9).toLong(), adaptiveRestMs(films(72), null, 7 * day))
|
||||
// The same films in an 8-hour block last three times as long in days: 80% of 15, never under 7.
|
||||
assertEquals((15 * day * 0.8).toLong(), adaptiveRestMs(films(72), DayPart(21, 5), 7 * day))
|
||||
// Just past a week: kept at the channel's own 7 days.
|
||||
assertEquals(7 * day, adaptiveRestMs(films(125), null, 7 * day))
|
||||
// Floor and ceiling.
|
||||
assertEquals(ADAPTIVE_REST_FLOOR_MS, adaptiveRestMs(films(10), null, 7 * day))
|
||||
assertEquals(ADAPTIVE_REST_CEILING_MS, adaptiveRestMs(films(500), null, 7 * day))
|
||||
}
|
||||
|
||||
@Test fun aSmallPoolPicksFromARestedShortlistInsteadOfAFixedLoop() {
|
||||
val pool = films(72)
|
||||
val flat = extendFilmSchedule(pool, ScheduleCursor(), start, start + 28 * day, 7 * day)
|
||||
val adaptive = extendFilmSchedule(pool, ScheduleCursor(), start, start + 28 * day, 7 * day, adaptiveRest = true)
|
||||
assertTrue(flat.entries.count { "no film past its rest" in it.why } > 200)
|
||||
assertEquals(0, adaptive.entries.count { "no film past its rest" in it.why })
|
||||
// Every film still rests at least the adaptive time.
|
||||
adaptive.entries.groupBy { it.seriesId }.values.forEach { es -> es.zipWithNext().forEach { (a, b) -> assertTrue(b.startMs - a.startMs >= adaptiveRestMs(pool, null, 7 * day)) } }
|
||||
adaptive.entries.zipWithNext().forEach { (a, b) -> assertEquals(a.endMs, b.startMs) }
|
||||
}
|
||||
|
||||
@Test fun eventsKeepTheChannelsRestAndOnlyTheChosenChannelsAdapt() {
|
||||
val pool = films(72)
|
||||
val event = DayPart(20, 23, pool.take(6).map { it.title }, days = setOf(java.time.DayOfWeek.FRIDAY))
|
||||
val plan = extendFilmSchedule(pool, ScheduleCursor(), start, start + 28 * day, 7 * day, listOf(event, DayPart(0, 24)), zone, adaptiveRest = true)
|
||||
plan.entries.filter { "event" in it.why && "picked from" in it.why }.groupBy { it.seriesId }.values.forEach { es -> es.zipWithNext().forEach { (a, b) -> assertTrue(b.startMs - a.startMs >= 7 * day) } }
|
||||
assertEquals(setOf(301, 305), SmartChannels.filter { it.adaptiveFilmRest }.map { it.number }.toSet())
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class EditorialCorrectionsAuditTest {
|
||||
val plan = current[p.number] ?: continue
|
||||
val others = clashesWith(current.filterKeys { it != p.number }.values.toList())
|
||||
current[p.number] = topUpPlan(plan, plan.tail, pools.getValue(p.number), now, p.filmRestMs, p.finishTogether, p.dayParts, zone, others,
|
||||
shuffle = p.shuffleEpisodes, mixed = p::mixes, weightOf = p.tierWeights?.let { p::weightOf }) ?: plan
|
||||
shuffle = p.shuffleEpisodes, mixed = p::mixes, weightOf = p.tierWeights?.let { p::weightOf }, adaptiveRest = p.adaptiveFilmRest) ?: plan
|
||||
current.getValue(p.number).entries.filter { e -> all.getValue(p.number).none { it.startMs == e.startMs } }.forEach { all.getValue(p.number) += it }
|
||||
}
|
||||
now += 6 * hour
|
||||
@@ -135,6 +135,29 @@ class EditorialCorrectionsAuditTest {
|
||||
"${es.size} screenings, ${es.map { it.media.item.id }.distinct().size} different; early returns (rest not kept) $fallbacks; " +
|
||||
(if (gaps.isNotEmpty()) "repeat gap median ${"%.1f".format(gaps[gaps.size / 2])} d, shortest ${"%.1f".format(gaps.first())} d" else "no repeats"))
|
||||
}
|
||||
// 5b. The same four weeks with adaptive rest on every film channel's everyday blocks, everything else as it is.
|
||||
out.appendLine()
|
||||
out.appendLine("== 5b. Adaptive rest (90% of a short block's play-through time, or up to 80% of a long one but never under 7 days), flat 7 days -> adaptive")
|
||||
val adaptive = network(channels.map { if (it.filmRestMs != null) it.copy(adaptiveFilmRest = true) else it }, pools, plans, from)
|
||||
for (p in filmPools.sortedBy { it.number }) {
|
||||
fun stats(r: Map<Int, List<ScheduleEntry>>): String {
|
||||
val es = r.getValue(p.number).filter { it.startMs >= plans.getValue(p.number).endMs && it.media.item.type == "Movie" }
|
||||
val gaps = es.groupBy { it.media.item.id }.values.flatMap { x -> x.zipWithNext().map { (a, b) -> (b.startMs - a.startMs) / day.toDouble() } }.sorted()
|
||||
val shortlist = es.mapNotNull { Regex("picked from (\\d+) rested").find(it.why)?.groupValues?.get(1)?.toInt() }.sorted()
|
||||
return "${es.map { it.media.item.id }.distinct().size} different, fixed-order fallbacks ${es.count { "no film past its rest" in it.why }}, " +
|
||||
"shortlist median ${shortlist.getOrNull(shortlist.size / 2) ?: 0}, repeat gap median ${"%.1f".format(gaps.getOrElse(gaps.size / 2) { 0.0 })} d, shortest ${"%.1f".format(gaps.firstOrNull() ?: 0.0)} d"
|
||||
}
|
||||
val rests = p.dayParts.filter { it.days.isEmpty() }.ifEmpty { listOf(null) }.map { part ->
|
||||
val (available, _, _) = if (part == null) Triple(pools.getValue(p.number), "", null) else dayPartFor(pools.getValue(p.number), listOf(part), java.time.LocalDate.of(2026, 11, 16).atTime(part.fromHour, 30).atZone(zone).toInstant().toEpochMilli(), zone)
|
||||
val films = available.filter { it.isFilm }.ifEmpty { pools.getValue(p.number).filter { it.isFilm } }
|
||||
(part?.let { "${it.fromHour}-${it.toHour} " } ?: "") + "%.1f d".format(adaptiveRestMs(films, part, p.filmRestMs!!) / day.toDouble())
|
||||
}
|
||||
out.appendLine(" ${p.number} ${p.name}: rest ${rests.joinToString()}")
|
||||
out.appendLine(" flat: ${stats(run)}")
|
||||
out.appendLine(" adaptive: ${stats(adaptive)}")
|
||||
}
|
||||
val adaptiveClashes = adaptive.flatMap { (n, es) -> es.map { n to it } }.groupBy { title(it.second) }.values.sumOf { list -> list.indices.sumOf { i -> list.drop(i + 1).count { b -> b.first != list[i].first && list[i].second.startMs < b.second.endMs && b.second.startMs < list[i].second.endMs } } }
|
||||
out.appendLine(" overlaps with adaptive rest, all channels: $adaptiveClashes (the committed Shaun of the Dead included)")
|
||||
File(dir, "editorial-corrections.txt").writeText(out.toString())
|
||||
println(out)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class ReplayFingerprintTest {
|
||||
val all = committed.entries.toMutableList()
|
||||
while (now < end) {
|
||||
current = topUpPlan(current, current.tail, series, now, programming.filmRestMs, programming.finishTogether, programming.dayParts, zone,
|
||||
shuffle = programming.shuffleEpisodes, mixed = programming::mixes, weightOf = programming.tierWeights?.let { programming::weightOf }) ?: break
|
||||
shuffle = programming.shuffleEpisodes, mixed = programming::mixes, weightOf = programming.tierWeights?.let { programming::weightOf }, adaptiveRest = programming.adaptiveFilmRest) ?: break
|
||||
current.entries.filter { e -> all.none { it.startMs == e.startMs } }.forEach { all += it }
|
||||
now += 6 * 60 * 60_000L
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Orbit TV 0.99.3: adaptive film rest (After Dark and Premiere)
|
||||
|
||||
This is the fifth isolated editorial correction, from the proposal of 4 November 2026. The change is to scheduling only, for two film channels.
|
||||
|
||||
## What's in it
|
||||
|
||||
- **`adaptiveRestMs`** (ChannelSchedule.kt). A film channel's everyday block can rest each film for a time worked out from how long the block's own films take to play through, back to back, in the block's daily hours:
|
||||
- **Too short for the channel's 7 days:** 90% of that time. Each pick then comes from a genuinely rested shortlist, not the "longest waiting" fallback, which plays the pool in the same fixed order every cycle.
|
||||
- **Longer than 7 days:** up to 80% of it, never under 7 days, so a big pool airs more of itself.
|
||||
- **Floor and ceiling:** 2 and 14 days.
|
||||
- **Events keep the channel's rest.** That covers B-Movie Throwbacks, Cult Classics, Joe Bob Saturdays and every other event. The Drive-In and PPV Sunday aren't affected.
|
||||
- **On for two channels only** (`ChannelProgramming.adaptiveFilmRest`):
|
||||
- **After Dark:** late 21:00 to 05:00 rests 14 days; day 05:00 to 21:00 rests 5.0 days, where flat 7 days can't be kept.
|
||||
- **Premiere:** 7.7 days.
|
||||
- **Every other film channel is unchanged**, for the reasons below.
|
||||
|
||||
## Why only these two
|
||||
|
||||
Four weeks of every channel booking together on box copies from 4 November 00:40, flat 7 days against adaptive for every film channel (docs/replays/editorial-corrections-2026-11-04.txt, section 5b):
|
||||
|
||||
| Channel | Rest | Different films | Fixed-order fallbacks | Repeat gap, median / shortest |
|
||||
|---|---|---|---|---|
|
||||
| After Dark | 14 d late, 5.0 d day | 126 → 132 | 190 → 0 | 5.7 / 5.2 → 5.4 / 5.0 d |
|
||||
| Premiere | 7.7 d | 97 → 98 | 0 → 0 | 8.6 / 7.0 → 9.1 / 7.7 d |
|
||||
| Action, Sci-Fi, Horror, Romance | 7.0 d | the same | 0 → 0 | the same within 0.2 d |
|
||||
| VHS | 6.2 d | 96 → 96 | 235 → 0 | 6.9 / 6.9 → 6.7 / 6.2 d |
|
||||
| Detour | 5.5 d | 88 → 88 | 261 → 0 | 6.1 / 6.1 → 5.9 / 5.5 d |
|
||||
| BritX | 5.8 d | 90 → 90 | 256 → 0 | 6.4 / 6.4 → 6.2 / 5.8 d |
|
||||
| Wonder | 5.0 d | 92 → 92 | 303 → 0 | 5.6 / 5.6 → 5.4 / 5.0 d |
|
||||
| PixelZ | 6.1 d | 100 → 100 | 217 → 0 | 6.8 / 6.8 → 6.7 / 6.1 d |
|
||||
|
||||
- **After Dark** gains six more films over four weeks, and its day block stops looping.
|
||||
- **Premiere** rests its films longer.
|
||||
- **The five small channels** (VHS, Detour, BritX, Wonder and PixelZ):
|
||||
- The fixed-order loop ends, but films come back about a fifth of a day sooner.
|
||||
- The loop already gives each film the longest possible gap. So the real fix for these channels is more films, not a different rest.
|
||||
- Switching one on later is a one-line change.
|
||||
|
||||
## Checks before install
|
||||
|
||||
- **408 unit tests pass**, including the hand-run replays. Lint has no errors.
|
||||
- **New AdaptiveFilmRestTest:**
|
||||
- The rest follows the block's films and hours, with the floor, ceiling and 7-day minimum for big pools.
|
||||
- A small pool picks from a rested shortlist with no fallbacks, keeps the adaptive rest and leaves no gaps.
|
||||
- Events keep 7 days.
|
||||
- Only 301 and 305 adapt.
|
||||
- **Fingerprints:** a four-week replay of all 30 channels against 0.99.2. Every committed fingerprint is identical, and only 301 and 305 differ.
|
||||
- **Clashes:** 0 new clashes with adaptive rest on every film channel. The only overlap is the old committed Shaun of the Dead.
|
||||
|
||||
## Known limits
|
||||
|
||||
- After Dark's pool is still waiting for Paul's review. Removing films would shorten its day-block rest automatically, because the rest follows the pool.
|
||||
- Tested here as scheduling logic only.
|
||||
|
||||
## Rollback
|
||||
|
||||
Install 0.99.2. No saved data changes.
|
||||
@@ -6,9 +6,9 @@ Editorial corrections: read-only figures from copies of the box's files taken 4
|
||||
films in more than one film channel's pool: 37
|
||||
|
||||
== 3. Ring X weeknights, 18:00 Monday to Saturday: how late the night starts
|
||||
Today: 19 nights; started late by TUE 48 min, WED 23 min, THU 10 min, FRI 47 min, SAT 41 min, MON 105 min, TUE 2 min, WED 6 min, THU 36 min, FRI 6 min, SAT 34 min, MON 23 min, TUE 79 min, WED 85 min, THU 45 min, FRI 26 min, SAT 6 min, MON 7 min, TUE 63 min
|
||||
median 34 min, worst 105 min, within 10 minutes 6 of 19
|
||||
gaps 0; daytime programmes chosen to finish in time: 2
|
||||
Today: 19 nights; started late by TUE 2 min, WED 19 min, THU 12 min, FRI 5 min, SAT 10 min, MON 12 min, TUE 3 min, WED 8 min, THU 3 min, FRI 17 min, SAT 6 min, MON 2 min, TUE 7 min, WED 9 min, THU 5 min, FRI 2 min, SAT 37 min, MON 30 min, TUE 18 min
|
||||
median 8 min, worst 37 min, within 10 minutes 12 of 19
|
||||
gaps 0; daytime programmes chosen to finish in time: 19
|
||||
Weeknights on time: 19 nights; started late by TUE 2 min, WED 19 min, THU 12 min, FRI 5 min, SAT 10 min, MON 12 min, TUE 3 min, WED 8 min, THU 3 min, FRI 17 min, SAT 6 min, MON 2 min, TUE 7 min, WED 9 min, THU 5 min, FRI 2 min, SAT 37 min, MON 30 min, TUE 18 min
|
||||
median 8 min, worst 37 min, within 10 minutes 12 of 19
|
||||
gaps 0; daytime programmes chosen to finish in time: 19
|
||||
@@ -16,31 +16,67 @@ Editorial corrections: read-only figures from copies of the box's files taken 4
|
||||
== 4. Titles on a channel's list with no match in its pool (exact name, no substitution)
|
||||
107 Evidence: 1 of 31 unmatched: Castle
|
||||
201 Terra: 4 of 46 unmatched: Our Planet II; Dynasties II; South Pacific; Great Barrier Reef
|
||||
202 Odyssey: 13 of 49 unmatched: Cosmos: A Spacetime Odyssey; Apollo 11; Engineering the Impossible; Big Bigger Biggest; Air Crash Investigation; Civilizations; The Vietnam War; Egypt's Lost Cities; Rome's Greatest Battles; Ancient Apocalypse; Parts Unknown; Michael Palin's Himalaya; Pole to Pole
|
||||
202 Odyssey: 19 of 56 unmatched: Cosmos: A Spacetime Odyssey; Apollo 11; Engineering the Impossible; Big Bigger Biggest; Air Crash Investigation; Civilizations; Civilisations (2018); The Vietnam War; The Vietnam War (2017); Egypt's Lost Cities; Rome's Greatest Battles; Ancient Apocalypse; Ancient Apocalypse (2022); Parts Unknown; Anthony Bourdain: Parts Unknown; Michael Palin's Himalaya; Himalaya with Michael Palin; Pole to Pole; Pole to Pole with Michael Palin
|
||||
203 Orbit Wild: 3 of 28 unmatched: Crocodile Hunter Diaries; Monster Fish; Dangerous Encounters with Brady Barr
|
||||
204 Dark Files: 6 of 52 unmatched: The Staircase; Crime Scene: The Vanishing at the Cecil Hotel; Homicide Hunter; Ancient Mysteries; Hangar 1: The UFO Files; My Ghost Story
|
||||
204 Dark Files: 10 of 56 unmatched: The Staircase; The Staircase (2004); Crime Scene: The Vanishing at the Cecil Hotel; Crime Scene; Homicide Hunter; Homicide Hunter: Lt. Joe Kenda; Ancient Mysteries; Hangar 1: The UFO Files; My Ghost Story; My Ghost Story: Caught on Camera
|
||||
302 Orbit Action: 4 of 108 unmatched: Rambo: First Blood; Bloodsport; Crank; Crank
|
||||
303 Orbit Sci-Fi: 1 of 100 unmatched: Alien 3
|
||||
303 Orbit Sci-Fi: 1 of 101 unmatched: Alien 3
|
||||
304 Orbit Horror: 2 of 115 unmatched: Ringu; Pet Sematary Two
|
||||
308 Detour: 3 of 91 unmatched: Van Wilder; Van Wilder: The Rise of Taj; Borat
|
||||
309 BritX: 2 of 93 unmatched: Green Street; Alan Partridge
|
||||
401 Ring X: 25 of 65 unmatched: WWE Monday Night RAW; WWF Monday Night RAW; WWF Raw; WWF RAW is WAR; WCW Nitro; TNA iMPACT!; TNA Impact!; TNA Impact Wrestling; TNA Wrestling; AEW Dynamite; AEW Rampage; AEW Collision; AEW Dark; WWF SmackDown; WWE Friday Night SmackDown; ECW on TNN; WWE ECW; WWF Superstars; WWF Attitude; WrestleMania; WWE WrestleMania; WWE Pay-Per-View; WWF Pay-Per-View; WCW Pay-Per-View; ECW Pay-Per-View
|
||||
601 Vortex: 7 of 33 unmatched: Justice League Unlimited; Voltron; Gundam Wing; Tenchi Muyo; Tenchi Universe; Cardcaptors; Zoids
|
||||
601 Vortex: 8 of 34 unmatched: Justice League Unlimited; Voltron; Gundam Wing; Tenchi Muyo; Tenchi Universe; Tenchi Muyo! Tenchi Universe; Cardcaptors; Zoids
|
||||
602 Heroes: 1 of 20 unmatched: Justice League Unlimited
|
||||
603 Orbit X: 3 of 24 unmatched: Digimon Adventure; Mighty Morphin Power Rangers; G.I. Joe: A Real American Hero
|
||||
605 ToonZ: 7 of 24 unmatched: Popeye; Dastardly and Muttley in Their Flying Machines; The Pink Panther Show; Merrie Melodies; The Bugs Bunny Show; The Tom and Jerry Show; Woody Woodpecker
|
||||
611 Orbit Junior: 7 of 55 unmatched: Thomas & Friends; The Clangers; Rainbow; Noddy; Balamory; Fimbles; Bluey
|
||||
612 Wonder: 2 of 94 unmatched: The Secret World of Arrietty; The Tale of Princess Kaguya
|
||||
611 Orbit Junior: 9 of 57 unmatched: Thomas & Friends; The Clangers; Rainbow; Noddy; Noddy's Toyland Adventures; Balamory; Fimbles; Bluey; Bluey (2018)
|
||||
612 Wonder: 4 of 96 unmatched: The Secret World of Arrietty; Arrietty (2010); The Tale of Princess Kaguya; The Tale of The Princess Kaguya
|
||||
|
||||
== 5. Film channels: pool, how long the pool lasts, and how the 7-day rest is kept (four weeks of new bookings)
|
||||
301 Orbit Premiere: 98 films, 231 h of film (9.6 days back to back); 217 screenings, 97 different; early returns (rest not kept) 0; repeat gap median 8.6 d, shortest 7.0 d
|
||||
301 Orbit Premiere: 98 films, 231 h of film (9.6 days back to back); 216 screenings, 98 different; early returns (rest not kept) 0; repeat gap median 8.8 d, shortest 7.7 d
|
||||
302 Orbit Action: 104 films, 201 h of film (8.4 days back to back); 264 screenings, 104 different; early returns (rest not kept) 0; repeat gap median 7.8 d, shortest 7.0 d
|
||||
303 Orbit Sci-Fi: 98 films, 199 h of film (8.3 days back to back); 252 screenings, 98 different; early returns (rest not kept) 0; repeat gap median 7.7 d, shortest 7.0 d
|
||||
304 Orbit Horror: 113 films, 193 h of film (8.0 days back to back); 298 screenings, 113 different; early returns (rest not kept) 0; repeat gap median 7.8 d, shortest 7.0 d
|
||||
305 After Dark: 169 films, 296 h of film (12.4 days back to back); 286 screenings, 126 different; early returns (rest not kept) 190; repeat gap median 5.7 d, shortest 5.2 d
|
||||
303 Orbit Sci-Fi: 98 films, 199 h of film (8.3 days back to back); 252 screenings, 98 different; early returns (rest not kept) 0; repeat gap median 7.9 d, shortest 7.0 d
|
||||
304 Orbit Horror: 113 films, 193 h of film (8.0 days back to back); 300 screenings, 113 different; early returns (rest not kept) 0; repeat gap median 7.7 d, shortest 7.0 d
|
||||
305 After Dark: 169 films, 296 h of film (12.4 days back to back); 284 screenings, 132 different; early returns (rest not kept) 0; repeat gap median 5.3 d, shortest 5.0 d
|
||||
306 Orbit VHS: 96 films, 166 h of film (6.9 days back to back); 295 screenings, 96 different; early returns (rest not kept) 235; repeat gap median 6.9 d, shortest 6.9 d
|
||||
307 Orbit Romance: 98 films, 190 h of film (7.9 days back to back); 262 screenings, 98 different; early returns (rest not kept) 0; repeat gap median 7.5 d, shortest 7.0 d
|
||||
308 Detour: 88 films, 146 h of film (6.1 days back to back); 308 screenings, 88 different; early returns (rest not kept) 261; repeat gap median 6.1 d, shortest 6.1 d
|
||||
309 BritX: 90 films, 154 h of film (6.4 days back to back); 298 screenings, 90 different; early returns (rest not kept) 256; repeat gap median 6.4 d, shortest 6.4 d
|
||||
612 Wonder: 92 films, 134 h of film (5.6 days back to back); 351 screenings, 92 different; early returns (rest not kept) 303; repeat gap median 5.6 d, shortest 5.6 d
|
||||
613 PixelZ: 100 films, 164 h of film (6.8 days back to back); 314 screenings, 100 different; early returns (rest not kept) 217; repeat gap median 6.8 d, shortest 6.8 d
|
||||
|
||||
== 5b. Adaptive rest (90% of a short block's play-through time, or up to 80% of a long one but never under 7 days), flat 7 days -> adaptive
|
||||
301 Orbit Premiere: rest 7.7 d
|
||||
flat: 98 different, fixed-order fallbacks 0, shortlist median 21, repeat gap median 8.8 d, shortest 7.7 d
|
||||
adaptive: 98 different, fixed-order fallbacks 0, shortlist median 20, repeat gap median 9.1 d, shortest 7.7 d
|
||||
302 Orbit Action: rest 7.0 d
|
||||
flat: 104 different, fixed-order fallbacks 0, shortlist median 18, repeat gap median 7.8 d, shortest 7.0 d
|
||||
adaptive: 104 different, fixed-order fallbacks 0, shortlist median 18, repeat gap median 7.8 d, shortest 7.0 d
|
||||
303 Orbit Sci-Fi: rest 7.0 d
|
||||
flat: 98 different, fixed-order fallbacks 0, shortlist median 16, repeat gap median 7.9 d, shortest 7.0 d
|
||||
adaptive: 98 different, fixed-order fallbacks 0, shortlist median 16, repeat gap median 7.9 d, shortest 7.0 d
|
||||
304 Orbit Horror: rest 7.0 d
|
||||
flat: 113 different, fixed-order fallbacks 0, shortlist median 16, repeat gap median 7.7 d, shortest 7.0 d
|
||||
adaptive: 113 different, fixed-order fallbacks 0, shortlist median 16, repeat gap median 7.7 d, shortest 7.0 d
|
||||
305 After Dark: rest 21-5 14.0 d, 5-21 5.0 d
|
||||
flat: 132 different, fixed-order fallbacks 0, shortlist median 6, repeat gap median 5.3 d, shortest 5.0 d
|
||||
adaptive: 132 different, fixed-order fallbacks 0, shortlist median 6, repeat gap median 5.4 d, shortest 5.0 d
|
||||
306 Orbit VHS: rest 6.2 d
|
||||
flat: 96 different, fixed-order fallbacks 235, shortlist median 9, repeat gap median 6.9 d, shortest 6.9 d
|
||||
adaptive: 96 different, fixed-order fallbacks 0, shortlist median 10, repeat gap median 6.7 d, shortest 6.2 d
|
||||
307 Orbit Romance: rest 7.0 d
|
||||
flat: 98 different, fixed-order fallbacks 0, shortlist median 12, repeat gap median 7.5 d, shortest 7.0 d
|
||||
adaptive: 98 different, fixed-order fallbacks 0, shortlist median 12, repeat gap median 7.5 d, shortest 7.0 d
|
||||
308 Detour: rest 5.5 d
|
||||
flat: 88 different, fixed-order fallbacks 261, shortlist median 24, repeat gap median 6.1 d, shortest 6.1 d
|
||||
adaptive: 88 different, fixed-order fallbacks 0, shortlist median 10, repeat gap median 5.9 d, shortest 5.5 d
|
||||
309 BritX: rest 5.8 d
|
||||
flat: 90 different, fixed-order fallbacks 256, shortlist median 22, repeat gap median 6.4 d, shortest 6.4 d
|
||||
adaptive: 90 different, fixed-order fallbacks 0, shortlist median 10, repeat gap median 6.2 d, shortest 5.8 d
|
||||
612 Wonder: rest 5.0 d
|
||||
flat: 92 different, fixed-order fallbacks 303, shortlist median 25, repeat gap median 5.6 d, shortest 5.6 d
|
||||
adaptive: 92 different, fixed-order fallbacks 0, shortlist median 10, repeat gap median 5.4 d, shortest 5.0 d
|
||||
613 PixelZ: rest 6.1 d
|
||||
flat: 100 different, fixed-order fallbacks 217, shortlist median 15, repeat gap median 6.8 d, shortest 6.8 d
|
||||
adaptive: 100 different, fixed-order fallbacks 0, shortlist median 11, repeat gap median 6.7 d, shortest 6.1 d
|
||||
overlaps with adaptive rest, all channels: 1 (the committed Shaun of the Dead included)
|
||||
|
||||
Reference in New Issue
Block a user