diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 00cbc672..3797aea8 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -9,8 +9,8 @@ android { applicationId = "tv.orbit.classic" minSdk = 26 targetSdk = 36 - versionCode = 157 - versionName = "0.108.0-drive-in-events" + versionCode = 158 + versionName = "0.109.0-advent" } buildFeatures { compose = true } compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 } diff --git a/android/app/src/main/java/tv/orbit/classic/AdventOnOrbit.kt b/android/app/src/main/java/tv/orbit/classic/AdventOnOrbit.kt new file mode 100644 index 00000000..31c96bad --- /dev/null +++ b/android/app/src/main/java/tv/orbit/classic/AdventOnOrbit.kt @@ -0,0 +1,79 @@ +package tv.orbit.classic + +import java.time.Instant +import java.time.LocalDateTime +import java.time.Month +import java.time.ZoneId + +/** + * Advent on Orbit (approved by Paul on 4 November 2026; docs/advent-on-orbit-proposal.md): one confirmed Christmas film a day, + * 1 to 25 December, across Wonder, VHS, Premiere and BritX, each behind a numbered door. Every film is pinned by its library + * item and IMDb ID and verified on the box like the Drive-In events ([checkEventFilm]); a door whose film fails isn't booked, + * and the channel carries on as usual. Doors are fixed slots ([FixedSlot]) that only append to a channel's plan, so nothing + * already booked changes, and each door's film is held out of every rotation, the Drive-In's included, either side of it. + */ +internal class AdventDoor(val door: Int, val channel: Int, val at: LocalDateTime, val film: EventFilm) + +private const val WONDER = 612 +private const val VHS = 306 +private const val PREMIERE = 301 +private const val BRITX = 309 +private fun dec(day: Int, hour: Int = 18) = LocalDateTime.of(2026, Month.DECEMBER, day, hour, 0) + +internal val AdventDoors: List = listOf( + AdventDoor(1, WONDER, dec(1), EventFilm("The Polar Express", 2004, "tt0338348", "5688746")), + AdventDoor(2, VHS, dec(2), EventFilm("Scrooged", 1988, "tt0096061", "5706930")), + AdventDoor(3, BRITX, dec(3), EventFilm("Get Santa", 2014, "tt1935940", "5642871")), + AdventDoor(4, PREMIERE, dec(4), EventFilm("Fred Claus", 2007, "tt0486583", "6048904")), + AdventDoor(5, VHS, dec(5), EventFilm("Home Alone 2: Lost in New York", 1992, "tt0104431", "7416998")), + AdventDoor(6, WONDER, dec(6), EventFilm("Klaus", 2019, "tt4729430", "5847706")), + AdventDoor(7, PREMIERE, dec(7), EventFilm("The Christmas Chronicles", 2018, "tt2990140", "5848529")), + AdventDoor(8, VHS, dec(8), EventFilm("The Santa Clause", 1994, "tt0111070", "5684856")), + AdventDoor(9, BRITX, dec(9), EventFilm("A Boy Called Christmas", 2021, "tt10187208", "6399934")), + AdventDoor(10, WONDER, dec(10), EventFilm("The Nightmare Before Christmas", 1993, "tt0107688", "5848040")), + AdventDoor(11, VHS, dec(11), EventFilm("Jingle All the Way", 1996, "tt0116705", "6062933")), + AdventDoor(12, PREMIERE, dec(12), EventFilm("How the Grinch Stole Christmas", 2000, "tt0170016", "5848691")), + AdventDoor(13, WONDER, dec(13), EventFilm("Arthur Christmas", 2011, "tt1430607", "5689513")), + AdventDoor(14, VHS, dec(14), EventFilm("A Christmas Story", 1983, "tt0085334", "6259980")), + AdventDoor(15, BRITX, dec(15), EventFilm("Nativity!", 2009, "tt1242447", "6056877")), + AdventDoor(16, WONDER, dec(16), EventFilm("A Christmas Carol", 2009, "tt1067106", "6035893")), + AdventDoor(17, VHS, dec(17), EventFilm("Santa Claus: The Movie", 1985, "tt0089961", "6933347")), + AdventDoor(18, PREMIERE, dec(18), EventFilm("Red One", 2024, "tt14948432", "6948638")), + // Moved off 18:00 so it ends before the Drive-In's Christmas triple opens at 19:00 (Paul asked for 16:30; the engine books on the hour). + AdventDoor(19, VHS, dec(19, 17), EventFilm("National Lampoon's Christmas Vacation", 1989, "tt0097958", "5848022")), + AdventDoor(20, WONDER, dec(20), EventFilm("The Grinch", 2018, "tt2709692", "5689633")), + AdventDoor(21, BRITX, dec(21), EventFilm("Last Christmas", 2019, "tt8623904", "6067366")), + AdventDoor(22, PREMIERE, dec(22), EventFilm("White Christmas", 1954, "tt0047673", "6048026")), + AdventDoor(23, BRITX, dec(23), EventFilm("Scrooge", 1951, "tt0044008", "7485376")), + AdventDoor(24, PREMIERE, dec(24), EventFilm("Miracle on 34th Street", 1947, "tt0039628", "5688583")), + AdventDoor(25, WONDER, dec(25, 17), EventFilm("The Muppet Christmas Carol", 1992, "tt0104940", "5847993"))) + +internal const val ADVENT_WHY = "advent: Door " +internal const val ADVENT_DOOR_KEY = "advent.door" +internal const val ADVENT_DOOR_25_KEY = "advent.door25" +/** Where the verified Advent films are kept, beside the channels' own pools. Not a channel. */ +internal const val ADVENT_POOL = 9025 +/** How long either side of its door a film is kept out of every rotation. */ +internal const val ADVENT_HOLD_MS = 14 * 24 * 60 * 60_000L + +/** A door's number from a broadcast's own start, in local time: the day of December, 1 to 25, or null outside Advent. */ +internal fun adventDoorNumber(startMs: Long, zone: ZoneId = ZoneId.systemDefault()): Int? = + Instant.ofEpochMilli(startMs).atZone(zone).takeIf { it.month == Month.DECEMBER && it.dayOfMonth in 1..25 }?.dayOfMonth + +/** This channel's doors whose films are verified ([films], by item), as fixed slots. */ +internal fun adventSlots(channel: Int, films: Map, zone: ZoneId = ZoneId.systemDefault()): List = + AdventDoors.filter { it.channel == channel }.mapNotNull { door -> + val film = films[door.film.itemId] ?: return@mapNotNull null + FixedSlot(door.at.atZone(zone).toInstant().toEpochMilli(), film, "$ADVENT_WHY${door.door}; fixed, approved 4 November 2026", + if (door.door == 25) ADVENT_DOOR_25_KEY else ADVENT_DOOR_KEY) + } + +/** + * Whether [film] is held for a door near [atMs]: the same library item, or the same title, within [ADVENT_HOLD_MS] of its door. + * Its own door doesn't count here, since the door is booked as a fixed slot, not from rotation. + */ +internal fun adventHeld(zone: ZoneId = ZoneId.systemDefault()): (PoolSeries, Long) -> Boolean { + val doors = AdventDoors.map { it to it.at.atZone(zone).toInstant().toEpochMilli() } + return { film, atMs -> doors.any { (door, doorMs) -> + (film.id == door.film.itemId || seriesKey(film.title) == seriesKey(door.film.title)) && kotlin.math.abs(atMs - doorMs) < ADVENT_HOLD_MS } } +} diff --git a/android/app/src/main/java/tv/orbit/classic/BlockIdents.kt b/android/app/src/main/java/tv/orbit/classic/BlockIdents.kt index ee676ac2..1b6c5350 100644 --- a/android/app/src/main/java/tv/orbit/classic/BlockIdents.kt +++ b/android/app/src/main/java/tv/orbit/classic/BlockIdents.kt @@ -28,7 +28,7 @@ import androidx.tv.material3.Text internal const val BLOCK_IDENT_MS = 4_000L /** What the app draws over a shared clip, so one film serves many nights or events. */ -internal enum class BlockOverlay { None, RingXNight, TonightsEvent } +internal enum class BlockOverlay { None, RingXNight, TonightsEvent, AdventDoor, AdventDoor25 } internal data class BlockIdent(val video: Int, val sting: Int, val overlay: BlockOverlay = BlockOverlay.None) @@ -52,6 +52,9 @@ internal val BlockIdents: Map = mapOf( "orbit2.spooky" to BlockIdent(R.raw.block_orbit2_spooky, R.raw.block_orbit2_spooky_sting), "ringx.ppv" to BlockIdent(R.raw.block_ringx_ppv, R.raw.block_ringx_ppv_sting, BlockOverlay.TonightsEvent), "terra.sunday" to BlockIdent(R.raw.block_terra_sunday, R.raw.block_terra_sunday_sting), + // Advent on Orbit (approved 4 November 2026): one shared door for Doors 1 to 24, numbered and filled from the booking, and Door 25's own. + ADVENT_DOOR_KEY to BlockIdent(R.raw.block_advent_door, R.raw.block_advent_door_sting, BlockOverlay.AdventDoor), + ADVENT_DOOR_25_KEY to BlockIdent(R.raw.block_advent_door25, R.raw.block_advent_door25_sting, BlockOverlay.AdventDoor25), ) + RingXNights.keys.associateWith { BlockIdent(R.raw.block_ringx_nights, R.raw.block_ringx_nights_sting, BlockOverlay.RingXNight) } /** Orbit's own names for Ring X's weekly nights (approved 3 November 2026), and each night's rope colour. */ @@ -79,6 +82,65 @@ internal fun BlockOverlayLayer(ident: BlockIdent, next: SampleBroadcast, positio BlockOverlay.None -> Unit BlockOverlay.RingXNight -> RingXNightOverlay(next.presentation, clock) BlockOverlay.TonightsEvent -> eventTitle(next)?.let { TonightLowerThird(it, clock) } + BlockOverlay.AdventDoor, BlockOverlay.AdventDoor25 -> adventDoorNumber(next.startMs)?.let { door -> + AdventDoorOverlay(door, eventTitle(next).orEmpty(), clock, ident.overlay == BlockOverlay.AdventDoor25) } + } +} + +/** + * Where the opening door sits in the shared Advent clip, every third frame of its 30 fps camera move and then its hold, in the + * clip's 1280x720 frame (from build_block_ident.py's points.json): left, top, right, bottom. + */ +private val AdventDoorTrack = floatArrayOf(672f, 276f, 786f, 408f, 672f, 276f, 786f, 408f, 671f, 276f, 786f, 409f, 670f, 275f, 786f, 409f, 668f, 275f, 786f, 410f, 667f, 274f, 786f, 412f, + 664f, 273f, 786f, 413f, 661f, 271f, 786f, 415f, 658f, 270f, 786f, 418f, 654f, 268f, 786f, 420f, 650f, 266f, 786f, 423f, 645f, 264f, 786f, 426f, 640f, 261f, 786f, 430f, + 634f, 258f, 786f, 434f, 628f, 255f, 786f, 438f, 621f, 252f, 786f, 443f, 613f, 248f, 786f, 448f, 605f, 244f, 787f, 454f, 596f, 239f, 787f, 460f, 586f, 235f, 787f, 467f, + 575f, 230f, 787f, 474f, 565f, 224f, 787f, 481f, 553f, 219f, 787f, 489f, 542f, 213f, 787f, 497f, 531f, 208f, 787f, 504f, 520f, 203f, 787f, 511f, 511f, 198f, 788f, 518f, + 502f, 194f, 788f, 524f, 496f, 191f, 788f, 528f, 493f, 189f, 788f, 530f, 492f, 189f, 788f, 531f, 492f, 189f, 788f, 531f, 492f, 189f, 788f, 531f) +/** Door 25's two leaves together once open, in the same frame. */ +private val AdventDoor25Open = floatArrayOf(413f, 220f, 867f, 701f) + +private fun adventDoorAt(t: Long): FloatArray { + val frame = (t / (1000f / 30f)).coerceIn(0f, 95f) / 3f + val i = frame.toInt().coerceAtMost(AdventDoorTrack.size / 4 - 2); val u = frame - i + return FloatArray(4) { k -> AdventDoorTrack[i * 4 + k] + (AdventDoorTrack[(i + 1) * 4 + k] - AdventDoorTrack[i * 4 + k]) * u } +} + +/** + * Advent's door: its number, from the broadcast's own date, glows on the chosen door from 0.6 s and goes as it opens; the + * booked film's title appears inside from 2.75 s; the strap names the door from 2.3 s. Door 25's greeting and strap are in + * its clip, so only the film is drawn. All settled by 3.2 s, before the hold. + */ +@Composable +private fun AdventDoorOverlay(door: Int, title: String, t: Long, door25: Boolean) { + var box by remember { mutableStateOf(IntSize.Zero) } + val gold = Color(0xFFF2C14E); val ink = Color(0xFF0E2147) + Box(Modifier.fillMaxSize().onSizeChanged { box = it }) { + if (box.width == 0) return@Box + val density = LocalDensity.current + val sx = box.width / 1280f; val sy = box.height / 720f + @Composable fun at(rect: FloatArray, content: @Composable BoxScope.() -> Unit) = Box(Modifier + .offset(with(density) { (rect[0] * sx).toDp() }, with(density) { (rect[1] * sy).toDp() }) + .size(with(density) { ((rect[2] - rect[0]) * sx).toDp() }, with(density) { ((rect[3] - rect[1]) * sy).toDp() }), contentAlignment = Alignment.Center, content = content) + val number = ease(ramp(t, 600, 400)) * (1 - ease(ramp(t, 1_750, 200))) + if (!door25 && number > 0f) { + val rect = adventDoorAt(t) + at(rect) { Text("$door", Modifier.graphicsLayer { alpha = number }, color = gold, fontSize = with(density) { ((rect[3] - rect[1]) * sy * .45f).toSp() }, fontWeight = FontWeight.Bold) } + } + val reveal = ease(ramp(t, 2_750, 450)) + if (reveal > 0f && title.isNotEmpty()) { + val rect = if (door25) AdventDoor25Open.copyOf().also { it[1] += (it[3] - it[1]) * .32f } else adventDoorAt(3_200) + at(rect) { + Text(title.uppercase(java.util.Locale.UK), Modifier.padding(horizontal = 10.dp).graphicsLayer { alpha = reveal }, color = ink, textAlign = TextAlign.Center, + fontSize = with(density) { ((rect[2] - rect[0]) * sx * (if (title.length > 24) .1f else .13f)).toSp() }, fontWeight = FontWeight.Bold, maxLines = 4, overflow = TextOverflow.Ellipsis) + } + } + val strap = ease(ramp(t, 2_300, 500)) + if (!door25 && strap > 0f) { + Box(Modifier.align(Alignment.BottomCenter).fillMaxWidth().height(with(density) { (92f * sy).toDp() }).graphicsLayer { alpha = strap; translationY = (1 - strap) * 30f * sy } + .background(Color(0xE6060E24)), contentAlignment = Alignment.Center) { + Text("ADVENT ON ORBIT · DOOR $door", color = gold, fontSize = with(density) { (34f * sy).toSp() }, fontWeight = FontWeight.SemiBold, letterSpacing = 6.sp, maxLines = 1) + } + } } } diff --git a/android/app/src/main/java/tv/orbit/classic/ChannelSchedule.kt b/android/app/src/main/java/tv/orbit/classic/ChannelSchedule.kt index 2dfefdac..8d916da8 100644 --- a/android/app/src/main/java/tv/orbit/classic/ChannelSchedule.kt +++ b/android/app/src/main/java/tv/orbit/classic/ChannelSchedule.kt @@ -435,15 +435,32 @@ internal fun chooseFilm(pool: List, shown: Map, startM /** Films by their rest period, back to back from [fromMs] until [untilMs] is covered. */ internal fun extendFilmSchedule(pool: List, cursor: ScheduleCursor, fromMs: Long, untilMs: Long, restMs: Long, dayParts: List = emptyList(), zone: java.time.ZoneId = java.time.ZoneId.systemDefault(), avoid: ProgrammeClash = { _, _, _ -> false }, - adaptiveRest: Boolean = false): ChannelPlan { + adaptiveRest: Boolean = false, fixed: List = emptyList(), held: (PoolSeries, Long) -> Boolean = { _, _ -> false }): ChannelPlan { val shown = cursor.filmShown.toMutableMap() val entries = mutableListOf() var last = cursor.lastSeriesId var start = fromMs val marks = cursor.marks.toMutableMap() val blockRest = HashMap() + // Fixed slots still ahead of what's booked, soonest first. One whose time has already been filled isn't booked late. + val slots = fixed.filter { it.startMs >= fromMs && it.startMs < untilMs }.sortedBy { it.startMs }.toMutableList() while (start < untilMs) { - val (available, block, part) = dayPartFor(pool, dayParts, start, zone) + val slot = slots.firstOrNull() + if (slot != null && start >= slot.startMs) { + slots.removeAt(0) + if (start - slot.startMs <= FIXED_SLOT_LATE_MS) { + val copy = slot.film.episodes.first() + entries += ScheduleEntry(slot.film.id, copy.mark, ScheduledMedia(SampleItem(slot.film.title, "Movie", copy.durationMs / 60_000, "", copy.id, copy.durationMs), copy.sourceId, copy.durationMs), + start, slot.why + if (start > slot.startMs) "; started ${(start - slot.startMs) / 60_000} min after its time" else "", slot.presentation) + shown[slot.film.id] = start + last = slot.film.id + start += copy.durationMs + } + continue + } + val (heldOut, block, part) = dayPartFor(pool, dayParts, start, zone) + // A film held for a fixed slot (here or anywhere on Orbit) stays out of rotation either side of it. + val available = heldOut.filter { !held(it, start) }.ifEmpty { heldOut } // An event naming only a series plays its next whole episode, once a night. Everywhere else is films only. val series = available.singleOrNull()?.takeIf { !it.isFilm && block.startsWith("event ") } if (series != null && shown[series.id]?.let { start - it < SERIES_NIGHT_MS } != true) { @@ -456,12 +473,20 @@ internal fun extendFilmSchedule(pool: List, cursor: ScheduleCursor, start += episode.durationMs continue } - val films = available.filter { it.isFilm }.ifEmpty { pool.filter { it.isFilm } }.ifEmpty { available } + val films = available.filter { it.isFilm }.ifEmpty { pool.filter { it.isFilm && !held(it, start) } }.ifEmpty { available } // 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()) blockRest.getOrPut(part) { sharedAdaptiveRestMs(pool, dayParts, part, restMs) } else restMs var (film, why) = chooseFilm(films, shown, start, rest, avoid) // Before an appointment, a rested film that leaves it on time, picked in the same seeded order as any other. - val appointment = if (part?.onTime == true) null else nextAppointment(start, zone, (ON_TIME_FILM_RUN_IN_MS / (60 * 60_000L)).toInt()) { at -> dayPartFor(pool, dayParts, at, zone) } + val dayAppointment = if (part?.onTime == true) null else nextAppointment(start, zone, (ON_TIME_FILM_RUN_IN_MS / (60 * 60_000L)).toInt()) { at -> dayPartFor(pool, dayParts, at, zone) } + val slotAhead = slot?.takeIf { it.startMs - start <= ON_TIME_FILM_RUN_IN_MS && (dayAppointment == null || it.startMs <= dayAppointment) } + // Before a fixed slot, the films are planned as a run that lands on its time: see [runToSlot]. + val toSlot = slotAhead?.let { runToSlot(it.startMs, start, films.filter { f -> !avoid(f, start, start + f.episodes.first().durationMs) }, shown, rest) } + if (toSlot != null) { + film = toSlot + why = "$why; chosen so the fixed slot at ${java.time.Instant.ofEpochMilli(slotAhead.startMs).atZone(zone).toLocalTime()} starts on time" + } + val appointment = if (toSlot != null) null else listOfNotNull(dayAppointment, slotAhead?.startMs).minOrNull() if (appointment != null) { val clear = films.filter { f -> !avoid(f, start, start + f.episodes.first().durationMs) } // Rested films in the same seeded order as any other pick; when none is rested, the longest waiting first, as the fallback would. @@ -540,6 +565,46 @@ 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. */ private const val ON_TIME_LOOKAHEAD_HOURS = 4 private const val ON_TIME_GRACE_MS = 20 * 60_000L + +/** + * A film fixed to a time on a film channel (Advent on Orbit's doors, approved by Paul on 4 November 2026). The films before it + * are chosen to finish by its time, as for any appointment, so it starts on time or within the usual grace; it's booked + * once, only when its time comes inside a top-up, and never in place of anything already booked. + */ +internal class FixedSlot(val startMs: Long, val film: PoolSeries, val why: String, val presentation: String) + +/** A fixed slot whose time has passed by more than this when its turn comes isn't booked at all, rather than booked late. */ +internal const val FIXED_SLOT_LATE_MS = 30 * 60_000L +/** How late a run before a fixed slot may finish, tightest first. */ +private val FIXED_SLOT_LANDINGS = listOf(5 * 60_000L, 12 * 60_000L, 20 * 60_000L) + +/** + * The first film of a run of up to three, back to back from [start], that ends at [slotMs] or just after it, so a fixed + * slot starts on time. Rested films first, in the planner's seeded order; then, only if no rested run lands, films not + * shown in the last two days. Null when nothing lands, and the planner's own choice stands. + */ +internal fun runToSlot(slotMs: Long, start: Long, films: List, shown: Map, restMs: Long): PoolSeries? { + fun len(f: PoolSeries) = f.episodes.first().durationMs + val remaining = slotMs - start + if (remaining <= 0) return null + val rested = films.filter { f -> shown[f.id]?.let { start - it >= restMs } != false }.shuffled(java.util.Random(start)).take(40) + val recent = films.filter { f -> f !in rested && shown[f.id]?.let { start - it >= 2 * 24 * 60 * 60_000L } != false }.sortedBy { shown[it.id] ?: Long.MIN_VALUE }.take(40) + for (pool in listOf(rested, rested + recent)) for (late in FIXED_SLOT_LANDINGS) { + fun lands(total: Long) = total in remaining..remaining + late + for (a in pool) { + if (len(a) > remaining + late) continue + if (lands(len(a))) return a + for (b in pool) { + if (b === a) continue + val two = len(a) + len(b) + if (two > remaining + late) continue + if (lands(two)) return a + if (pool.any { c -> c !== a && c !== b && lands(two + len(c)) }) return a + } + } + } + return null +} /** An appointment's window is its first hour; a programme must end inside it for the appointment to happen at all. */ private const val ON_TIME_LAST_CALL_MS = 60 * 60_000L /** How long before an appointment the programmes leading into it may be adjusted. */ @@ -827,9 +892,11 @@ internal fun extendSchedule(pool: List, cursor: ScheduleCursor, from /** Off only in tests: each block keeps its own place in the rotation. */ blockRotation: Boolean = true, /** Film channels only: see [ChannelProgramming.adaptiveFilmRest]. */ - adaptiveRest: Boolean = false): ChannelPlan { + adaptiveRest: Boolean = false, + /** Film channels only: see [FixedSlot]. */ + fixed: List = emptyList(), held: (PoolSeries, Long) -> Boolean = { _, _ -> false }): ChannelPlan { require(pool.isNotEmpty() && pool.all { it.episodes.isNotEmpty() }) - if (filmRestMs != null) return extendFilmSchedule(pool, cursor, fromMs, untilMs, filmRestMs, dayParts, zone, avoid, adaptiveRest) + if (filmRestMs != null) return extendFilmSchedule(pool, cursor, fromMs, untilMs, filmRestMs, dayParts, zone, avoid, adaptiveRest, fixed, held) val marks = cursor.marks.toMutableMap() val entries = mutableListOf() var last = cursor.lastSeriesId @@ -965,7 +1032,9 @@ internal fun topUpPlan(existing: ChannelPlan?, aired: ScheduleCursor, pool: List /** Weighted channels only: see [extendWeighted]. */ fileRestMs: Long = SAME_FILE_MS, /** Weighted channels only: see [ChannelProgramming.storyGrouping]. */ - stories: Boolean = false): ChannelPlan? { + stories: Boolean = false, + /** Film channels only: see [FixedSlot]. */ + fixed: List = emptyList(), held: (PoolSeries, Long) -> 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 @@ -974,7 +1043,7 @@ internal fun topUpPlan(existing: ChannelPlan?, aired: ScheduleCursor, pool: List val added = if (weightOf != null && filmRestMs == null) { val recent = kept?.entries.orEmpty().filter { it.startMs >= from - fileRestMs }.associate { it.media.item.id to it.startMs } extendByBlock(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, weightOf, dayParts, zone, avoid, shuffle, mixed, finishTogether, recent, trailing, fileRestMs, stories) - } else extendSchedule(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, filmRestMs, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing, noThirdInARow, blockRotation, adaptiveRest) + } else extendSchedule(pool, existing?.tail ?: aired, from, nowMs + SCHEDULE_AHEAD_MS, filmRestMs, finishTogether, dayParts, zone, avoid, shuffle, mixed, trailing, noThirdInARow, blockRotation, adaptiveRest, fixed, held) return ChannelPlan(kept?.entries.orEmpty() + added.entries, added.tail) } diff --git a/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt b/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt index c20bc135..39e576b0 100644 --- a/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt +++ b/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt @@ -80,12 +80,33 @@ internal class ChannelScheduler(private val store: ScheduleStore, private val cl val events = DriveInEvents.filter { !it.evening.isBefore(java.time.Instant.ofEpochMilli(now).atZone(java.time.ZoneId.systemDefault()).toLocalDate().minusDays(1)) } val eventFilms = withoutFailed(eventFilms(userId, session, events, now), failed).associateBy { it.id } val plan = planDriveIn(existing, films(DriveInMarqueeChannels), films(DriveInLateChannels), films(DriveInBillChannels), now, avoid = avoid, - events = events, eventFilms = eventFilms, note = { Log.i("OrbitSchedule", "channel=$DRIVE_IN_NUMBER $it") }) ?: return existing + events = events, eventFilms = eventFilms, note = { Log.i("OrbitSchedule", "channel=$DRIVE_IN_NUMBER $it") }, alsoHeld = adventHeld()) ?: return existing if (plan !== existing) store.savePlan(userId, DRIVE_IN_NUMBER, plan) Log.i("OrbitSchedule", "channel=$DRIVE_IN_NUMBER programmes=${plan.entries.size}") return plan } + /** + * The Advent doors' verified films, read at most once a day, and only from mid-November, when the first door comes inside + * a week's booking. A read that fails keeps the last verified list; with no verified film, a door simply isn't booked. + */ + private fun adventFilms(userId: String, session: EmbySampleSession, now: Long): List { + val first = AdventDoors.minOf { it.at.atZone(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli() } + val last = AdventDoors.maxOf { it.at.atZone(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli() } + if (now < first - SCHEDULE_AHEAD_MS - 2 * 24 * 60 * 60_000L || now > last) return emptyList() + val signature = "advent:" + AdventDoors.joinToString(",") { it.film.itemId } + val saved = store.loadPool(userId, ADVENT_POOL)?.takeIf { it.signature == signature } + if (saved != null && now - saved.fetchedAtMs < 24 * 60 * 60_000L) return saved.series + return try { + val checks = session.readFilmChecks(AdventDoors.map { it.film to null }) + Log.i("OrbitSchedule", "advent films=${checks.size} " + checks.values.groupingBy { it.reason }.eachCount().entries.joinToString(" ") { "${it.key.replace(' ', '_')}=${it.value}" }) + withoutFailed(checks.values.mapNotNull { it.film }, store.loadFailed(userId)).also { store.savePool(userId, ADVENT_POOL, ScheduleStore.SavedPool(it, now, signature)) } + } catch (failure: EmbyCheckException) { + Log.w("OrbitSchedule", "advent films failed=${failure.javaClass.simpleName} status=${failure.httpStatus}") + saved?.series.orEmpty() + } + } + /** * The curated events' verified films, read at most once a day, and only when the Drive-In is about to book. A read that * fails keeps the last verified list; with no session, the saved list is used as it is. @@ -178,9 +199,14 @@ internal class ChannelScheduler(private val store: ScheduleStore, private val cl clashesWithAirings((SmartChannels.map { it.number }.filter { it != number } + DRIVE_IN_NUMBER).flatMap { airingsOn(userId, it) }) .also { othersMs = android.os.SystemClock.elapsedRealtime() - began } } + // Advent on Orbit: this channel's doors as fixed slots, from films verified on the box; every film channel holds them back. + val fixed = if (programming.filmRestMs != null && AdventDoors.any { it.channel == number }) adventSlots(number, adventFilms(userId, session, now).associateBy { it.id }) else emptyList() 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 }, adaptiveRest = programming.adaptiveFilmRest, stories = programming.storyGrouping) ?: throw EmbyCheckException("${programming.name} has no episodes to schedule.") + weightOf = programming.tierWeights?.let { programming::weightOf }, adaptiveRest = programming.adaptiveFilmRest, stories = programming.storyGrouping, + fixed = fixed, held = adventHeld()) ?: throw EmbyCheckException("${programming.name} has no episodes to schedule.") + if (plan !== existing) plan.entries.filter { it.why.startsWith(ADVENT_WHY) && existing?.entries?.none { e -> e.startMs == it.startMs } != false } + .forEach { Log.i("OrbitSchedule", "channel=$number advent door=${it.why.removePrefix(ADVENT_WHY).substringBefore(';')} booked lateMin=${(it.startMs - (fixed.firstOrNull { f -> f.film.id == it.seriesId }?.startMs ?: it.startMs)) / 60_000}") } if (plan !== existing) store.savePlan(userId, number, plan) // Stage C, report only: every work any plan books, so "not yet shown on Orbit" has evidence. if (plan !== existing) runCatching { diff --git a/android/app/src/main/java/tv/orbit/classic/DriveIn.kt b/android/app/src/main/java/tv/orbit/classic/DriveIn.kt index 6beb0a82..8b8c5026 100644 --- a/android/app/src/main/java/tv/orbit/classic/DriveIn.kt +++ b/android/app/src/main/java/tv/orbit/classic/DriveIn.kt @@ -117,7 +117,9 @@ internal fun lateShowEligible(film: PoolSeries) = film.episodes.first().duration */ internal fun planDriveIn(existing: ChannelPlan?, marquee: List, late: List, bills: List, nowMs: Long, zone: ZoneId = ZoneId.systemDefault(), avoid: ProgrammeClash = { _, _, _ -> false }, - events: List = emptyList(), eventFilms: Map = emptyMap(), note: (String) -> Unit = {}): ChannelPlan? { + events: List = emptyList(), eventFilms: Map = emptyMap(), note: (String) -> Unit = {}, + /** Films held for fixed slots elsewhere on Orbit (Advent's doors), kept out of the weekly rotation near them. */ + alsoHeld: (PoolSeries, Long) -> Boolean = { _, _ -> false }): ChannelPlan? { val kept = existing?.let { plan -> plan.copy(entries = plan.entries.dropWhile { it.endMs < nowMs - SCHEDULE_KEEP_PAST_MS }) } if (driveInBookedAhead(kept, nowMs, zone)) return kept if (marquee.isEmpty()) return kept @@ -129,7 +131,7 @@ internal fun planDriveIn(existing: ChannelPlan?, marquee: List, late fun eventStart(event: DriveInEvent) = event.evening.atTime(event.hour, event.minute).atZone(zone).toInstant().toEpochMilli() // An event's films are held back from the weekly rotation for a rest either side of it, so the event finds them rested. val held = events.filter { !it.evening.isBefore(date) }.flatMap { event -> event.films.map { film -> film to eventStart(event) } } - fun isHeld(film: PoolSeries, startMs: Long) = held.any { (event, at) -> + fun isHeld(film: PoolSeries, startMs: Long) = alsoHeld(film, startMs) || held.any { (event, at) -> (film.id == event.itemId || seriesKey(film.title) == seriesKey(event.title)) && kotlin.math.abs(at - startMs) < DRIVE_IN_REST_MS } fun free(pool: List, startMs: Long) = pool.filter { !isHeld(it, startMs) }.ifEmpty { pool } fun book(film: PoolSeries, startMs: Long, why: String = "", presentation: String = ""): Long = diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt index e43eec78..efc79b8a 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt @@ -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.108.0\"") + connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.109.0\"") request.token?.let { connection.setRequestProperty("X-Emby-Token", it) } if (request.method == "POST") { val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8) diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt index 1d415e5e..5b57c302 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt @@ -220,8 +220,11 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v * The curated Drive-In events' films, read by their exact library items in one request, with their media, IMDb IDs and * cast, each checked by [checkEventFilm]. Read only: nothing is changed in the library. */ - fun readEventFilms(events: List): Map { - val films = events.flatMap { event -> event.films.map { it to event.person } }.distinctBy { it.first.itemId } + fun readEventFilms(events: List): Map = readFilmChecks(events.flatMap { event -> event.films.map { it to event.person } }) + + /** Exact films, each with the person its cast must include (or null), read and checked as [readEventFilms] does. */ + fun readFilmChecks(listed: List>): Map { + val films = listed.distinctBy { it.first.itemId } val ids = films.map { it.first.itemId }.filter(EmbyClient::validId) if (ids.isEmpty()) return emptyMap() val reply = transport.execute(EmbyRequest("GET", "/Items?UserId=$userId&Ids=${ids.joinToString(",")}&Fields=MediaSources,ProviderIds,ProductionYear,People" + diff --git a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt index 54100505..ffe0bcf2 100644 --- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt +++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt @@ -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.108.0") + next.setRequestProperty("User-Agent", "OrbitTV/0.109.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()) { diff --git a/android/app/src/main/java/tv/orbit/classic/WhatsOnPage.kt b/android/app/src/main/java/tv/orbit/classic/WhatsOnPage.kt index 70ccbbd5..3ad381ac 100644 --- a/android/app/src/main/java/tv/orbit/classic/WhatsOnPage.kt +++ b/android/app/src/main/java/tv/orbit/classic/WhatsOnPage.kt @@ -43,6 +43,8 @@ internal fun whatsOnRule(channel: Int, entry: ScheduleEntry, zone: ZoneId): Trip val hour = Instant.ofEpochMilli(entry.startMs).atZone(zone).hour return when { "premiere: first airing on Orbit" in why -> Triple("FIRST ON ORBIT", "A first airing on Orbit", 100) + // An Advent door, only ever from its confirmed booking; its number is the broadcast's own date. + why.startsWith(ADVENT_WHY) -> adventDoorNumber(entry.startMs, zone)?.let { Triple("ADVENT ON ORBIT · DOOR $it", "Advent on Orbit", 90) } entry.presentation.isNotEmpty() && why.startsWith("event") -> Triple(if (channel == 401) "SPECIAL EVENT" else "WEEKLY EVENT", "A booked channel event", 80) why.contains("story: part 1 of") -> Triple("COMPLETE STORY", "A whole multi-part story, back to back", 60) entry.media.item.type == "Movie" && channel in 300..399 && hour in 19..22 -> Triple("TONIGHT'S FILM", "An evening film on a film channel", 40) diff --git a/android/app/src/main/res/raw/block_advent_door.mp4 b/android/app/src/main/res/raw/block_advent_door.mp4 new file mode 100644 index 00000000..a601a8b3 Binary files /dev/null and b/android/app/src/main/res/raw/block_advent_door.mp4 differ diff --git a/android/app/src/main/res/raw/block_advent_door25.mp4 b/android/app/src/main/res/raw/block_advent_door25.mp4 new file mode 100644 index 00000000..6998cf03 Binary files /dev/null and b/android/app/src/main/res/raw/block_advent_door25.mp4 differ diff --git a/android/app/src/main/res/raw/block_advent_door25_sting.m4a b/android/app/src/main/res/raw/block_advent_door25_sting.m4a new file mode 100644 index 00000000..dc157786 Binary files /dev/null and b/android/app/src/main/res/raw/block_advent_door25_sting.m4a differ diff --git a/android/app/src/main/res/raw/block_advent_door_sting.m4a b/android/app/src/main/res/raw/block_advent_door_sting.m4a new file mode 100644 index 00000000..e0206d04 Binary files /dev/null and b/android/app/src/main/res/raw/block_advent_door_sting.m4a differ diff --git a/android/app/src/test/java/tv/orbit/classic/AdventOnOrbitTest.kt b/android/app/src/test/java/tv/orbit/classic/AdventOnOrbitTest.kt new file mode 100644 index 00000000..2ecdbad5 --- /dev/null +++ b/android/app/src/test/java/tv/orbit/classic/AdventOnOrbitTest.kt @@ -0,0 +1,104 @@ +package tv.orbit.classic + +import org.junit.Assert.* +import org.junit.Test +import java.time.Instant +import java.time.ZoneId +import java.time.ZonedDateTime + +/** Advent on Orbit: 25 fixed doors that only ever append, held out of every rotation, numbered from their own broadcast dates. */ +class AdventOnOrbitTest { + private val london = ZoneId.of("Europe/London") + private val minute = 60_000L + private val day = 24 * 60 * minute + private fun film(title: String, minutes: Long, id: String = title.replace(Regex("[^A-Za-z0-9]"), "")) = + PoolSeries(id, title, listOf(PoolEpisode(id, "s$id", EpisodeMark(1, 1), title, minutes * minute))) + private fun at(month: Int, d: Int, h: Int, m: Int = 0) = ZonedDateTime.of(2026, month, d, h, m, 0, 0, london).toInstant().toEpochMilli() + private val pool = (1..60).map { film("Film $it", 85L + (it * 7) % 50) } + private val polar = film("The Polar Express", 99, "5688746") + private val klaus = film("Klaus", 98, "5847706") + + @Test fun theDoorsAreAsApproved() { + assertEquals((1..25).toList(), AdventDoors.map { it.door }) + AdventDoors.forEach { door -> + assertEquals(door.door, door.at.dayOfMonth) + assertEquals(java.time.Month.DECEMBER, door.at.month) + assertEquals(if (door.door == 19 || door.door == 25) 17 else 18, door.at.hour) + } + assertEquals(25, AdventDoors.map { it.film.itemId }.distinct().size) + assertEquals(setOf(612, 306, 301, 309), AdventDoors.map { it.channel }.toSet()) + assertEquals("The Muppet Christmas Carol", AdventDoors.last().film.title) + assertEquals(612, AdventDoors.last().channel) + // Nothing shared with the Drive-In's events, so the Christmas triple stays its own. + val driveIn = DriveInEvents.flatMap { it.films }.map { it.itemId }.toSet() + assertTrue(AdventDoors.none { it.film.itemId in driveIn }) + assertTrue(AdventDoors.all { it.film.imdb.matches(Regex("tt\\d{7,8}")) && EmbyClient.validId(it.film.itemId) }) + } + + @Test fun theDoorNumberIsTheBroadcastsOwnDate() { + assertEquals(12, adventDoorNumber(at(12, 12, 18), london)) + assertEquals(12, adventDoorNumber(at(12, 12, 0, 30), london)) + assertEquals(1, adventDoorNumber(at(12, 1, 0, 0), london)) + assertNull(adventDoorNumber(at(11, 30, 23, 59), london)) + assertNull(adventDoorNumber(at(12, 26, 18), london)) + } + + @Test fun aDoorIsBookedOnTimeAndOnlyAppends() { + val slot = FixedSlot(at(12, 1, 18), polar, "${ADVENT_WHY}1; fixed", ADVENT_DOOR_KEY) + val plan = extendFilmSchedule(pool, ScheduleCursor(), at(11, 30, 6), at(12, 3, 6), 7 * day, zone = london, fixed = listOf(slot)) + val door = plan.entries.single { it.seriesId == polar.id } + assertTrue(door.startMs in at(12, 1, 18)..at(12, 1, 18, 20)) + assertEquals(ADVENT_DOOR_KEY, door.presentation) + assertTrue(door.why.startsWith("${ADVENT_WHY}1")) + plan.entries.zipWithNext { a, b -> assertEquals(a.endMs, b.startMs) } + // Booked over committed programmes: everything committed stays exactly as it was. + val committed = extendFilmSchedule(pool, ScheduleCursor(), at(11, 28, 6), at(11, 30, 6), 7 * day, zone = london) + val topped = topUpPlan(ChannelPlan(committed.entries, committed.tail), ScheduleCursor(), pool, at(11, 29, 12), 7 * day, zone = london, fixed = listOf(slot))!! + assertTrue(committed.entries.filter { it.endMs > at(11, 29, 12) }.all { it in topped.entries }) + assertEquals(committed.entries.last(), topped.entries[topped.entries.indexOf(committed.entries.last())]) + assertEquals(1, topped.entries.count { it.seriesId == polar.id && it.why.startsWith(ADVENT_WHY) }) + } + + @Test fun aDoorWhoseTimeIsAlreadyBookedIsntSqueezedIn() { + // The plan is committed past 18:00 already: the door isn't booked late or over anything. + val committed = extendFilmSchedule(pool, ScheduleCursor(), at(11, 30, 6), at(12, 1, 22), 7 * day, zone = london) + val slot = FixedSlot(at(12, 1, 18), polar, "${ADVENT_WHY}1; fixed", ADVENT_DOOR_KEY) + val topped = topUpPlan(ChannelPlan(committed.entries, committed.tail), ScheduleCursor(), pool, at(12, 1, 12), 7 * day, zone = london, fixed = listOf(slot))!! + assertTrue(committed.entries.filter { it.endMs > at(12, 1, 12) }.all { it in topped.entries }) + assertTrue(topped.entries.none { it.why.startsWith(ADVENT_WHY) }) + } + + @Test fun doorFilmsAreHeldOutOfRotation() { + val held = adventHeld(london) + // Klaus is Door 6 (6 December): held from 22 November to 20 December, free outside it. + assertTrue(held(klaus, at(12, 1, 12))) + assertTrue(held(film("Klaus", 98, "another-copy"), at(12, 10, 12))) + assertFalse(held(klaus, at(11, 15, 12))) + assertFalse(held(film("Film 3", 100), at(12, 6, 12))) + val withKlaus = pool + klaus + val plan = extendFilmSchedule(withKlaus, ScheduleCursor(), at(11, 25, 6), at(12, 9, 6), 2 * day, zone = london, held = held) + assertTrue(plan.entries.none { it.seriesId == klaus.id }) + // And the Drive-In's weekly rotation holds it too. + var p: ChannelPlan? = null; var now = at(11, 25, 12) + while (now < at(12, 9, 12)) { p = planDriveIn(p, withKlaus, pool, emptyList(), now, london, alsoHeld = held); now += day } + assertTrue(p!!.entries.none { it.seriesId == klaus.id && kotlin.math.abs(it.startMs - at(12, 6, 18)) < ADVENT_HOLD_MS }) + } + + @Test fun onlyVerifiedDoorsBecomeSlots() { + val slots = adventSlots(612, mapOf(polar.id to polar), london) + assertEquals(1, slots.size) + assertEquals(at(12, 1, 18), slots.single().startMs) + assertTrue(adventSlots(612, emptyMap(), london).isEmpty()) + assertEquals(ADVENT_DOOR_25_KEY, adventSlots(612, mapOf("5847993" to film("The Muppet Christmas Carol", 86, "5847993")), london).single().presentation) + } + + @Test fun whatsOnShowsOnlyBookedDoors() { + val slot = FixedSlot(at(12, 1, 18), polar, "${ADVENT_WHY}1; fixed", ADVENT_DOOR_KEY) + val booked = extendFilmSchedule(pool, ScheduleCursor(), at(11, 30, 6), at(12, 3, 6), 7 * day, zone = london, fixed = listOf(slot)) + val page = whatsOnPage(mapOf(612 to booked), null, at(12, 1, 13), london) + assertEquals("ADVENT ON ORBIT · DOOR 1", page.pick!!.tag) + val unbooked = extendFilmSchedule(pool, ScheduleCursor(), at(11, 30, 6), at(12, 3, 6), 7 * day, zone = london) + val empty = whatsOnPage(mapOf(612 to unbooked), null, at(12, 1, 13), london) + assertTrue((listOfNotNull(empty.pick) + empty.tonight + empty.comingUp).none { it.tag.startsWith("ADVENT") }) + } +} diff --git a/android/app/src/test/java/tv/orbit/classic/AdventReplayTest.kt b/android/app/src/test/java/tv/orbit/classic/AdventReplayTest.kt new file mode 100644 index 00000000..fa37bd14 --- /dev/null +++ b/android/app/src/test/java/tv/orbit/classic/AdventReplayTest.kt @@ -0,0 +1,115 @@ +package tv.orbit.classic + +import org.json.JSONArray +import org.json.JSONObject +import org.junit.Assume.assumeTrue +import org.junit.Test +import java.io.File +import java.time.Instant +import java.time.ZoneId + +/** + * Advent's doors on copies of the box's own files, run by hand: + * ORBIT_REPLAY_DIR= ./gradlew :app:testDebugUnitTest --tests '*AdventReplayTest*' + * advent-films.json is the doors' films as the library catalogue has them ([{id, title, ms}]); on the box they also pass + * the decoder check first. Tops up every channel day by day to 27 December, as the box does, with and without Advent, and + * writes advent-doors.txt (each door as booked, how late, and every check) and advent-fingerprints.txt there. + */ +class AdventReplayTest { + private val dir = System.getenv("ORBIT_REPLAY_DIR")?.let(::File) + private val zone = ZoneId.of("Europe/London") + + private fun plan(file: File): ChannelPlan? { + if (!file.exists()) return null + val root = JSONObject(file.readText()); val rows = root.getJSONArray("entries"); val t = root.getJSONObject("tail"); val marks = t.getJSONObject("marks") + val entries = (0 until rows.length()).map { i -> + val o = rows.getJSONObject(i); val d = o.getLong("d"); val n = o.getJSONArray("n") + ScheduleEntry(o.getString("s"), EpisodeMark(n.getInt(0), n.getInt(1)), ScheduledMedia(SampleItem(o.getString("t"), o.optString("k", "Episode"), d / 60_000, "", o.getString("i"), d), o.getString("c"), d), + o.getLong("a"), o.optString("w"), o.optString("p")) + } + return ChannelPlan(entries, ScheduleCursor(if (t.isNull("last")) null else t.getString("last"), + marks.keys().asSequence().associateWith { id -> marks.getJSONArray(id).let { EpisodeMark(it.getInt(0), it.getInt(1)) } }, + t.optJSONObject("shown")?.let { s -> s.keys().asSequence().associateWith { s.getLong(it) } }.orEmpty(), + t.optJSONObject("blocks")?.let { b -> b.keys().asSequence().associateWith { b.getString(it) } }.orEmpty())) + } + + private fun pool(file: File): List { + val rows = JSONObject(file.readText()).getJSONArray("series") + return (0 until rows.length()).map { i -> + val o = rows.getJSONObject(i); val eps = o.getJSONArray("episodes") + PoolSeries(o.getString("id"), o.getString("title"), (0 until eps.length()).map { j -> + val e = eps.getJSONArray(j); PoolEpisode(e.getString(0), e.getString(1), EpisodeMark(e.getInt(2), e.getInt(3)), e.getString(4), e.getLong(5)) + }, o.optString("group")) + } + } + + private fun run(advent: Boolean): Map> { + val listed = JSONArray(File(dir, "advent-films.json").readText()) + val films = (0 until listed.length()).map { listed.getJSONObject(it) }.associate { o -> + o.getString("id") to PoolSeries(o.getString("id"), o.getString("title"), listOf(PoolEpisode(o.getString("id"), "src", EpisodeMark(1, 1), o.getString("title"), o.getLong("ms")))) + } + val held = if (advent) adventHeld(zone) else { _: PoolSeries, _: Long -> false } + val channels = SmartChannels.sortedBy { it.number }.filter { File(dir, "schedule-${it.number}.json").exists() && File(dir, "episodes-${it.number}.json").exists() } + val plans = channels.associate { it.number to plan(File(dir, "schedule-${it.number}.json"))!! }.toMutableMap() + val pools = channels.associate { it.number to pool(File(dir, "episodes-${it.number}.json")) } + val all = plans.mapValues { it.value.entries.toMutableList() }.toMutableMap() + var now = System.getenv("ORBIT_REPLAY_NOW")?.toLong() ?: plans.values.minOf { it.entries.first().startMs } + val end = java.time.LocalDate.of(2026, 12, 27).atStartOfDay(zone).toInstant().toEpochMilli() + while (now < end) { + for (programming in channels) { + val number = programming.number + val others = clashesWith(plans.filterKeys { it != number }.values.toList()) + val fixed = if (advent && programming.filmRestMs != null) adventSlots(number, films, zone) else emptyList() + val next = topUpPlan(plans[number], ScheduleCursor(), pools[number], now, programming.filmRestMs, programming.finishTogether, programming.dayParts, zone, others, + shuffle = programming.shuffleEpisodes, mixed = programming::mixes, weightOf = programming.tierWeights?.let { programming::weightOf }, + adaptiveRest = programming.adaptiveFilmRest, stories = programming.storyGrouping, fixed = fixed, held = held) ?: continue + plans[number] = next + next.entries.filter { e -> all[number]!!.none { it.startMs == e.startMs } }.forEach { all[number]!! += it } + } + now += 6 * 60 * 60_000L + } + return all + } + + @Test fun toBoxingDay() { + assumeTrue(dir != null && File(dir, "advent-films.json").exists()) + val with = run(true); val without = run(false) + val out = StringBuilder() + val doorStarts = AdventDoors.associate { it.door to it.at.atZone(zone).toInstant().toEpochMilli() } + for (door in AdventDoors) { + val booked = with[door.channel].orEmpty().firstOrNull { it.why.startsWith("$ADVENT_WHY${door.door};") } + val at = booked?.let { Instant.ofEpochMilli(it.startMs).atZone(zone) } + out.appendLine("Door %2d %-3d %s %s".format(door.door, door.channel, door.film.title, + if (booked == null) "NOT BOOKED" else "booked %s %02d:%02d (%+d min) %d min, key %s".format(at!!.toLocalDate(), at.hour, at.minute, (booked.startMs - doorStarts[door.door]!!) / 60_000, booked.media.durationMs / 60_000, booked.presentation))) + } + // Checks: no overlaps anywhere; committed bookings kept; no door film in any rotation within its hold; nothing changed on channels without doors before the holds. + val overlaps = with.mapValues { (_, e) -> e.sortedBy { it.startMs }.zipWithNext().count { (a, b) -> a.endMs > b.startMs } }.filterValues { it > 0 } + val holdBreaks = with.flatMap { (number, entries) -> entries.filter { e -> !e.why.startsWith(ADVENT_WHY) && AdventDoors.any { d -> + (e.seriesId == d.film.itemId || seriesKey(e.media.item.title) == seriesKey(d.film.title)) && kotlin.math.abs(e.startMs - doorStarts[d.door]!!) < ADVENT_HOLD_MS } }.map { "$number ${it.media.item.title}" } } + .filter { line -> AdventDoors.none { d -> line.endsWith(d.film.title) } || true } + val committed = SmartChannels.mapNotNull { p -> plan(File(dir, "schedule-${p.number}.json"))?.let { p.number to it } } + .count { (number, plan) -> with[number]?.take(plan.entries.size) != plan.entries } + val changed = with.keys.filter { with[it] != without[it] }.sorted() + out.appendLine() + out.appendLine("overlaps: $overlaps") + out.appendLine("committed plans changed: $committed") + out.appendLine("door films in rotation within the hold: ${holdBreaks.size} ${holdBreaks.take(10)}") + out.appendLine("channels whose bookings differ from the run without Advent: $changed") + for (number in changed) { + val a = with[number].orEmpty(); val b = without[number].orEmpty() + val first = a.zip(b).indexOfFirst { (x, y) -> x != y }.let { if (it < 0) minOf(a.size, b.size) else it } + val at = a.getOrNull(first) ?: b.getOrNull(first) + out.appendLine(" $number first differs at ${at?.let { Instant.ofEpochMilli(it.startMs).atZone(zone).toLocalDateTime() }}: ${b.getOrNull(first)?.media?.item?.title} -> ${a.getOrNull(first)?.media?.item?.title} | ${a.getOrNull(first)?.why?.take(110)}") + } + for (door in AdventDoors.filter { d -> with[d.channel].orEmpty().none { it.why.startsWith("$ADVENT_WHY${d.door};") } }) { + val at = doorStarts[door.door]!! + out.appendLine("around door ${door.door}:") + with[door.channel].orEmpty().filter { it.endMs > at - 4 * 60 * 60_000L && it.startMs < at + 60 * 60_000L }.forEach { e -> + val t = Instant.ofEpochMilli(e.startMs).atZone(zone) + out.appendLine(" %02d:%02d %3d min %s | %s".format(t.hour, t.minute, e.media.durationMs / 60_000, e.media.item.title, e.why.take(140))) + } + } + File(dir, "advent-doors.txt").writeText(out.toString()) + println(out) + } +} diff --git a/android/app/src/test/java/tv/orbit/classic/DriveInEventsReplayTest.kt b/android/app/src/test/java/tv/orbit/classic/DriveInEventsReplayTest.kt index 746bad71..cd12cea0 100644 --- a/android/app/src/test/java/tv/orbit/classic/DriveInEventsReplayTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/DriveInEventsReplayTest.kt @@ -59,7 +59,7 @@ class DriveInEventsReplayTest { var now = start val end = java.time.LocalDate.of(2026, 12, 21).atStartOfDay(zone).toInstant().toEpochMilli() while (now < end) { - current = planDriveIn(current, films(DriveInMarqueeChannels), films(DriveInLateChannels), films(DriveInBillChannels), now, zone, avoid, events, eventFilms) { notes += it } + current = planDriveIn(current, films(DriveInMarqueeChannels), films(DriveInLateChannels), films(DriveInBillChannels), now, zone, avoid, events, eventFilms, note = { notes += it }) current!!.entries.filter { e -> all.none { it.startMs == e.startMs } }.forEach { all += it } now += 24 * 60 * 60_000L } diff --git a/android/app/src/test/java/tv/orbit/classic/DriveInEventsTest.kt b/android/app/src/test/java/tv/orbit/classic/DriveInEventsTest.kt index 8b94d39d..c87c31fb 100644 --- a/android/app/src/test/java/tv/orbit/classic/DriveInEventsTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/DriveInEventsTest.kt @@ -42,7 +42,7 @@ class DriveInEventsTest { var now = from val all = existing?.entries.orEmpty().toMutableList() while (now < at(11, 30, 12)) { - plan = planDriveIn(plan, big, late, bills, now, london, avoid, events, films) { notes += it } + plan = planDriveIn(plan, big, late, bills, now, london, avoid, events, films, note = { notes += it }) plan!!.entries.filter { e -> all.none { it.startMs == e.startMs } }.forEach { all += it } now += 24 * 60 * minute } @@ -144,7 +144,7 @@ class DriveInEventsTest { assertTrue(lateShowEligible(film("Braindead", 97))) assertTrue(lateShowEligible(film("Thesis", 124))) val notes = mutableListOf() - val plan = planDriveIn(null, big, late + film("Extra Weird Sampler", 222), bills, at(11, 2, 12), london) { notes += it }!! + val plan = planDriveIn(null, big, late + film("Extra Weird Sampler", 222), bills, at(11, 2, 12), london, note = { notes += it })!! assertTrue(plan.entries.none { it.media.item.title == "Extra Weird Sampler" }) assertTrue("late excluded=1" in notes) } diff --git a/design/channels/advent-blocks/door-25-app/exports/door_25_app_guide.png b/design/channels/advent-blocks/door-25-app/exports/door_25_app_guide.png new file mode 100644 index 00000000..b1454d7f Binary files /dev/null and b/design/channels/advent-blocks/door-25-app/exports/door_25_app_guide.png differ diff --git a/design/channels/advent-blocks/door-25-app/exports/door_25_app_guide_app.webp b/design/channels/advent-blocks/door-25-app/exports/door_25_app_guide_app.webp new file mode 100644 index 00000000..e049f6af Binary files /dev/null and b/design/channels/advent-blocks/door-25-app/exports/door_25_app_guide_app.webp differ diff --git a/design/channels/advent-blocks/door-25-app/exports/door_25_app_ident.mp4 b/design/channels/advent-blocks/door-25-app/exports/door_25_app_ident.mp4 new file mode 100644 index 00000000..6998cf03 Binary files /dev/null and b/design/channels/advent-blocks/door-25-app/exports/door_25_app_ident.mp4 differ diff --git a/design/channels/advent-blocks/door-25-app/exports/door_25_app_sting.wav b/design/channels/advent-blocks/door-25-app/exports/door_25_app_sting.wav new file mode 100644 index 00000000..4ef2b594 Binary files /dev/null and b/design/channels/advent-blocks/door-25-app/exports/door_25_app_sting.wav differ diff --git a/design/channels/advent-blocks/door-25-app/review/checks.json b/design/channels/advent-blocks/door-25-app/review/checks.json new file mode 100644 index 00000000..bc1494e2 --- /dev/null +++ b/design/channels/advent-blocks/door-25-app/review/checks.json @@ -0,0 +1,28 @@ +{ + "status": "preview-not-integrated", + "block": "Advent Door 25, app clip", + "seconds": 4.0, + "fps": 30, + "size": [ + 1280, + 720 + ], + "crf": "34", + "identBytes": 116300, + "ssim": { + "mean": 0.9889, + "worst": 0.9849 + }, + "guideAppBytes": 3112, + "finalHoldStillForHalfSecond": true, + "flash": { + "frames": 120, + "largestFrameChange": 0.0128, + "framesChangingOver10Percent": 0, + "brightnessReversals": 0 + }, + "sting": { + "integratedLufs": -30.0, + "truePeakDbfs": -18.8 + } +} \ No newline at end of file diff --git a/design/channels/advent-blocks/door-25-app/review/door_25_app_contact_sheet.png b/design/channels/advent-blocks/door-25-app/review/door_25_app_contact_sheet.png new file mode 100644 index 00000000..c5737a39 Binary files /dev/null and b/design/channels/advent-blocks/door-25-app/review/door_25_app_contact_sheet.png differ diff --git a/design/channels/advent-blocks/door-25-app/review/door_25_app_final_still.png b/design/channels/advent-blocks/door-25-app/review/door_25_app_final_still.png new file mode 100644 index 00000000..e5b977ad Binary files /dev/null and b/design/channels/advent-blocks/door-25-app/review/door_25_app_final_still.png differ diff --git a/design/channels/advent-blocks/door-25-app/review/door_25_app_preview_silent.mp4 b/design/channels/advent-blocks/door-25-app/review/door_25_app_preview_silent.mp4 new file mode 100644 index 00000000..6998cf03 Binary files /dev/null and b/design/channels/advent-blocks/door-25-app/review/door_25_app_preview_silent.mp4 differ diff --git a/design/channels/advent-blocks/door-25-app/review/door_25_app_preview_with_sound.mp4 b/design/channels/advent-blocks/door-25-app/review/door_25_app_preview_with_sound.mp4 new file mode 100644 index 00000000..8b509307 Binary files /dev/null and b/design/channels/advent-blocks/door-25-app/review/door_25_app_preview_with_sound.mp4 differ diff --git a/design/channels/advent-blocks/door-app/exports/door_app_guide.png b/design/channels/advent-blocks/door-app/exports/door_app_guide.png new file mode 100644 index 00000000..b1454d7f Binary files /dev/null and b/design/channels/advent-blocks/door-app/exports/door_app_guide.png differ diff --git a/design/channels/advent-blocks/door-app/exports/door_app_guide_app.webp b/design/channels/advent-blocks/door-app/exports/door_app_guide_app.webp new file mode 100644 index 00000000..e049f6af Binary files /dev/null and b/design/channels/advent-blocks/door-app/exports/door_app_guide_app.webp differ diff --git a/design/channels/advent-blocks/door-app/exports/door_app_ident.mp4 b/design/channels/advent-blocks/door-app/exports/door_app_ident.mp4 new file mode 100644 index 00000000..a601a8b3 Binary files /dev/null and b/design/channels/advent-blocks/door-app/exports/door_app_ident.mp4 differ diff --git a/design/channels/advent-blocks/door-app/exports/door_app_sting.wav b/design/channels/advent-blocks/door-app/exports/door_app_sting.wav new file mode 100644 index 00000000..c4b42bac Binary files /dev/null and b/design/channels/advent-blocks/door-app/exports/door_app_sting.wav differ diff --git a/design/channels/advent-blocks/door-app/review/checks.json b/design/channels/advent-blocks/door-app/review/checks.json new file mode 100644 index 00000000..b52e51fd --- /dev/null +++ b/design/channels/advent-blocks/door-app/review/checks.json @@ -0,0 +1,28 @@ +{ + "status": "preview-not-integrated", + "block": "Advent door, app clip", + "seconds": 4.0, + "fps": 30, + "size": [ + 1280, + 720 + ], + "crf": "34", + "identBytes": 136065, + "ssim": { + "mean": 0.9836, + "worst": 0.9704 + }, + "guideAppBytes": 3112, + "finalHoldStillForHalfSecond": true, + "flash": { + "frames": 120, + "largestFrameChange": 0.0143, + "framesChangingOver10Percent": 0, + "brightnessReversals": 0 + }, + "sting": { + "integratedLufs": -30.0, + "truePeakDbfs": -17.9 + } +} \ No newline at end of file diff --git a/design/channels/advent-blocks/door-app/review/door_app_contact_sheet.png b/design/channels/advent-blocks/door-app/review/door_app_contact_sheet.png new file mode 100644 index 00000000..e126ee1c Binary files /dev/null and b/design/channels/advent-blocks/door-app/review/door_app_contact_sheet.png differ diff --git a/design/channels/advent-blocks/door-app/review/door_app_final_still.png b/design/channels/advent-blocks/door-app/review/door_app_final_still.png new file mode 100644 index 00000000..6b7c255c Binary files /dev/null and b/design/channels/advent-blocks/door-app/review/door_app_final_still.png differ diff --git a/design/channels/advent-blocks/door-app/review/door_app_preview_silent.mp4 b/design/channels/advent-blocks/door-app/review/door_app_preview_silent.mp4 new file mode 100644 index 00000000..a601a8b3 Binary files /dev/null and b/design/channels/advent-blocks/door-app/review/door_app_preview_silent.mp4 differ diff --git a/design/channels/advent-blocks/door-app/review/door_app_preview_with_sound.mp4 b/design/channels/advent-blocks/door-app/review/door_app_preview_with_sound.mp4 new file mode 100644 index 00000000..61a13c1a Binary files /dev/null and b/design/channels/advent-blocks/door-app/review/door_app_preview_with_sound.mp4 differ diff --git a/design/channels/batch7_review.png b/design/channels/batch7_review.png index de470b1e..fffb14cf 100644 Binary files a/design/channels/batch7_review.png and b/design/channels/batch7_review.png differ diff --git a/design/channels/build-batch7-blocks.py b/design/channels/build-batch7-blocks.py index e89cf3f9..6f43ccbd 100644 --- a/design/channels/build-batch7-blocks.py +++ b/design/channels/build-batch7-blocks.py @@ -26,6 +26,9 @@ BLOCKS = { 'advent': dict(title='Advent on Orbit, Doors 1 to 24', folder='advent-blocks/door', channel='orbit-premiere', sample=('12', 'HOW THE GRINCH STOLE CHRISTMAS')), 'advent25': dict(title='Advent on Orbit, Door 25', folder='advent-blocks/door-25', channel='orbit-premiere', sample=('25', 'THE MUPPET CHRISTMAS CAROL')), 'naughty': dict(title='After Dark: The Naughty List', folder='orbit-after-dark-blocks/naughty-list', channel='orbit-after-dark'), + # The clips the app plays: the door's number, the film and (for Doors 1 to 24) the strap are the app's, drawn from the booking. + 'advent_app': dict(title='Advent door, app clip', folder='advent-blocks/door-app', channel='orbit-premiere', scene='advent', app=True), + 'advent25_app': dict(title='Advent Door 25, app clip', folder='advent-blocks/door-25-app', channel='orbit-premiere', scene='advent25', app=True), } @@ -48,7 +51,7 @@ def wrapped(words, face, colour, width, spacing=2): class Block(b3.Block): def __init__(self, key, frames): - self.key, self.cfg, self.frames, self.cache = key, BLOCKS[key], Path(frames) / key, {} + self.key, self.cfg, self.frames, self.cache = key, BLOCKS[key], Path(frames) / BLOCKS[key].get('scene', key), {} self.points = json.loads((self.frames / 'points.json').read_text()) def door(self, pts): @@ -80,8 +83,8 @@ class Block(b3.Block): if big: greeting = self.cache.get('greet') or self.cache.setdefault('greet', wrapped('MERRY CHRISTMAS FROM ORBIT', font('barlow-semibold.ttf', 30), (120, 20, 24, 255), fw * .8, 4)) place(canvas, greeting, fcx - greeting.width / 2, final['top'] + fh * .14, reveal) - film = self.cache.get(('film', title)) or self.cache.setdefault(('film', title), wrapped(title, font('anton-regular.ttf', 50 if big else 54), NAVY + (255,), fw * .8, 2)) - place(canvas, film, fcx - film.width / 2, fcy - film.height / 2 + (fh * .1 if big else 0), reveal) + film = None if not title else self.cache.get(('film', title)) or self.cache.setdefault(('film', title), wrapped(title, font('anton-regular.ttf', 50 if big else 54), NAVY + (255,), fw * .8, 2)) + if film is not None: place(canvas, film, fcx - film.width / 2, fcy - film.height / 2 + (fh * .1 if big else 0), reveal) # The strap: Advent on Orbit, and the door's number. band = kf(t, [(2.3, 0), (2.8, 1)], ease_io) if band > 0: @@ -93,6 +96,13 @@ class Block(b3.Block): def draw_advent25(self, canvas, pts, t): self.draw_advent(canvas, pts, t, '25', 'THE MUPPET CHRISTMAS CAROL', big=True) + def draw_advent_app(self, canvas, pts, t): + pass + + def draw_advent25_app(self, canvas, pts, t): + # The greeting and Door 25's strap never change, so they're in the clip; the film is the app's. + self.draw_advent(canvas, pts, t, '25', '', big=True) + def draw_naughty(self, canvas, pts, t): # The room's gone dark by 3D's end; the title bleeds in, with one flicker, and holds. a = kf(t, [(2.95, 0), (3.1, .9), (3.16, .25), (3.24, 1)], ease_io) @@ -113,6 +123,8 @@ class Block(b3.Block): SOUNDS = { 'advent': lambda: riot.mix(LENGTH, [(1.0, b3.shimmer(1.4, 71), .3), (1.9, b3.bell(784.0), .45), (2.3, b3.bell(1046.5), .3)]), 'advent25': lambda: riot.mix(LENGTH, [(.8, b3.shimmer(2.0, 72), .35), (1.7, b3.bell(659.3), .45), (2.0, b3.bell(784.0), .4), (2.3, b3.bell(1046.5), .4)]), + 'advent_app': lambda: SOUNDS['advent'](), + 'advent25_app': lambda: SOUNDS['advent25'](), 'naughty': lambda: riot.mix(LENGTH, [(.3, b3.bell(1318.5, 1.2), .2), (1.4, b3.bell(1244.5, 1.2), .2), (2.7, riot.thump(.6, 55, 24, .4, 73), .9)]), } diff --git a/docs/VERIFICATION-0.109.0.md b/docs/VERIFICATION-0.109.0.md new file mode 100644 index 00000000..bcd6227a --- /dev/null +++ b/docs/VERIFICATION-0.109.0.md @@ -0,0 +1,58 @@ +# 0.109.0: Advent on Orbit, built and replayed, NOT installed + +Paul approved the 25-door list and the ident previews on 4 November 2026 ("those look perfect"). This release is built and verified only. **It isn't installed and nothing is booked**, and it needs his separate approval. The Naughty List and the anthology changes aren't in it. + +## What it does + +**The 25 doors** are in `AdventOnOrbit.kt`, each pinned by its Emby item and IMDb ID: Wonder 612, VHS 306, Premiere 301 and BritX 309. +- Doors 1 to 24 are at 18:00, except Door 19 at **17:00** (see the note below). +- Door 25 is at 17:00 on Wonder. + +**Verified on the box:** +- **When:** at most once a day, from about 22 November, when the first door comes inside a week's booking. +- **How:** in one read-only request, each film is checked by `checkEventFilm` as the Drive-In events are: the same item, the same IMDb ID, a year within one, and a copy this box can decode with a runtime. +- **What's saved:** the verified list goes to `episodes-9025.json`, and the log carries counts by reason only. +- **If a film fails:** its door isn't booked, and the channel carries on as usual. + +**Fixed slots** (`FixedSlot`, in `extendFilmSchedule`): +- **Only appends:** a door is booked only when its time comes inside a channel's normal top-up. Nothing already booked is touched. +- **No squeezing in:** a door whose time is already covered by committed bookings isn't booked late or over anything. +- **Landing on time:** before a door, `runToSlot` plans the films as a run of up to three that ends at the door's time or just after it. It prefers rested films, and uses others not shown in the last two days only if needed. If even that fails, the usual appointment fit applies. + +**The hold:** each door's film is kept out of every film channel's rotation, and the Drive-In's, for 14 days either side of its door. It matches by item or title (`adventHeld`). + +**Presentation:** +- **Keys:** `advent.door` (Doors 1 to 24) and `advent.door25` (Door 25). +- **Clips:** `res/raw/block_advent_door*.mp4` and stings, the app versions of the approved previews, with no number or title baked in. +- **What the app draws** (`AdventDoorOverlay`): the door number from the broadcast's own local date, tracked onto the opening door; the booked film's title inside the door; and the strap ADVENT ON ORBIT · DOOR N. +- **Door 25:** its greeting and strap are in its clip. +- **Fallback:** a booking without its door's key gets the channel's normal ident, as before. + +**What's On:** a booked door shows as **ADVENT ON ORBIT · DOOR N**, scoring above weekly events. An unbooked door appears nowhere. + +## Checks + +- **Tests:** 487 unit tests run, 0 failures; lint unchanged (the same 22 warnings as before, none new). `AdventOnOrbitTest` adds 7 tests: + - the doors as approved, with no film shared with the Drive-In events; + - the door number from the broadcast date, including after midnight and outside Advent; + - a door booked on time that only appends; + - a door whose time is already committed isn't squeezed in; + - holds in film channels and the Drive-In; + - only verified doors become slots; + - What's On shows booked doors only. +- **Replay on the box's own files** (copied at 20:27 today): `AdventReplayTest` tops up every channel every 6 hours from 4 November 20:30 to 27 December, with and without Advent. Output: `docs/replays/advent-doors-0.109.0.txt`. + - **All 25 doors are booked.** 21 start within 5 minutes of their time. The latest are Door 12 at +16, Door 22 at +14 (both on Premiere, whose films run 2 to 3 hours) and Door 19 at +12. + - Door 19 starts at 17:12 and ends at 18:49, before the Drive-In opens at 19:00. + - Door 25 starts at 17:04. + - No overlaps on any channel. + - 0 committed plans changed. + - 0 door films in any rotation within their hold. + - **Channels that differ from the run without Advent, all from 22 November onwards** (nothing committed): + - **The four door channels:** their doors and holds. + - **613 (Junior):** it had The Polar Express in its rotation, which is now held. + - **304, 602 and 603:** later knock-ons of the clash rule, as other channels' films move. +- **Rollback:** reinstall 0.108.0. Older versions ignore `episodes-9025.json`, and plans keep their format. Any door already booked would stay booked as an ordinary film, with no door ident. + +**Door 19:** Paul asked for 16:30. The engine books fixed slots on the hour, so it's set at 17:00 (ends by about 18:50) pending his choice of 17:00 or 16:00. Changing it is one line. + +APK: `outputs/revision-0.109.0`, signed. **Not installed.** diff --git a/docs/replays/advent-doors-0.109.0.txt b/docs/replays/advent-doors-0.109.0.txt new file mode 100644 index 00000000..84be09a3 --- /dev/null +++ b/docs/replays/advent-doors-0.109.0.txt @@ -0,0 +1,38 @@ +Door 1 612 The Polar Express booked 2026-12-01 18:03 (+3 min) 99 min, key advent.door +Door 2 306 Scrooged booked 2026-12-02 18:04 (+4 min) 101 min, key advent.door +Door 3 309 Get Santa booked 2026-12-03 18:01 (+1 min) 102 min, key advent.door +Door 4 301 Fred Claus booked 2026-12-04 18:03 (+3 min) 115 min, key advent.door +Door 5 306 Home Alone 2: Lost in New York booked 2026-12-05 18:00 (+0 min) 120 min, key advent.door +Door 6 612 Klaus booked 2026-12-06 18:01 (+1 min) 98 min, key advent.door +Door 7 301 The Christmas Chronicles booked 2026-12-07 18:00 (+0 min) 103 min, key advent.door +Door 8 306 The Santa Clause booked 2026-12-08 18:03 (+3 min) 97 min, key advent.door +Door 9 309 A Boy Called Christmas booked 2026-12-09 18:03 (+3 min) 106 min, key advent.door +Door 10 612 The Nightmare Before Christmas booked 2026-12-10 18:03 (+3 min) 76 min, key advent.door +Door 11 306 Jingle All the Way booked 2026-12-11 18:01 (+1 min) 93 min, key advent.door +Door 12 301 How the Grinch Stole Christmas booked 2026-12-12 18:16 (+16 min) 104 min, key advent.door +Door 13 612 Arthur Christmas booked 2026-12-13 18:01 (+1 min) 97 min, key advent.door +Door 14 306 A Christmas Story booked 2026-12-14 18:03 (+3 min) 93 min, key advent.door +Door 15 309 Nativity! booked 2026-12-15 18:01 (+1 min) 105 min, key advent.door +Door 16 612 A Christmas Carol booked 2026-12-16 18:03 (+3 min) 95 min, key advent.door +Door 17 306 Santa Claus: The Movie booked 2026-12-17 18:03 (+3 min) 108 min, key advent.door +Door 18 301 Red One booked 2026-12-18 18:04 (+4 min) 124 min, key advent.door +Door 19 306 National Lampoon's Christmas Vacation booked 2026-12-19 17:12 (+12 min) 97 min, key advent.door +Door 20 612 The Grinch booked 2026-12-20 18:04 (+4 min) 85 min, key advent.door +Door 21 309 Last Christmas booked 2026-12-21 18:02 (+2 min) 102 min, key advent.door +Door 22 301 White Christmas booked 2026-12-22 18:14 (+14 min) 120 min, key advent.door +Door 23 309 Scrooge booked 2026-12-23 18:00 (+0 min) 86 min, key advent.door +Door 24 301 Miracle on 34th Street booked 2026-12-24 18:03 (+3 min) 96 min, key advent.door +Door 25 612 The Muppet Christmas Carol booked 2026-12-25 17:04 (+4 min) 86 min, key advent.door25 + +overlaps: {} +committed plans changed: 0 +door films in rotation within the hold: 0 [] +channels whose bookings differ from the run without Advent: [301, 304, 306, 309, 602, 603, 612, 613] + 301 first differs at 2026-12-04T13:07:46.770: Apollo 13 -> Mission: Impossible - Fallout | whole pool; picked from 20 rested films, last shown 205h ago; chosen so the fixed slot at 18:00 starts on time + 304 first differs at 2026-12-11T05:19:05.418: Paranormal Activity -> The Exorcist | no block, whole pool; picked from 21 rested films, last shown 170h ago + 306 first differs at 2026-11-28T04:36:55.215: Home Alone 2: Lost in New York -> Beverly Hills Cop | whole pool; fallback: no film past its rest, so the longest waiting + 309 first differs at 2026-12-03T13:38:09.271: Control -> Control | whole pool; fallback: no film past its rest, so the longest waiting; chosen so the fixed slot at 18:00 starts + 602 first differs at 2026-12-20T08:01:02.325: Static Shock / S4 E8 / Now You See Him... -> The Batman / S3 E3 / A Dark Knight to Remember | block 6-15; weighted: lowest tally for its tier (412), others resting or just played + 603 first differs at 2026-12-28T10:36:23.734: The Transformers / S3 E13 / Madman's Paradise -> Exosquad / S2 E16 / Miracle | block 6-18; weighted: lowest tally for its tier (528), others resting or just played + 612 first differs at 2026-11-24T11:54:53.225: Klaus -> Castle in the Sky | whole pool; fallback: no film past its rest, so the longest waiting + 613 first differs at 2026-11-22T01:08:03.394: The Polar Express -> How to Train Your Dragon | whole pool; fallback: no film past its rest, so the longest waiting