Approvals without a block air on channels made only of named blocks; event names with years match (build 72)

On a channel whose every hour belongs to a named block, a title approved without a block
never aired (Terra's Blue Planet III and Africa). It now joins each everyday block, except
one kept on equal turns (Tots' Wind Down). Channels with an open block are unchanged.
An event named "AEW All Out (2019)" also finds the library's "AEW All Out 2019".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 12:39:15 +00:00
co-authored by Claude Opus 5.5
parent f2e9f31639
commit b802a760dc
4 changed files with 72 additions and 5 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ plugins {
id("org.jetbrains.kotlin.plugin.compose")
}
/** The release's build number: versionCode is this x 10 plus the edition's channel. */
val ORBIT_BUILD = 71
val ORBIT_BUILD = 72
android {
namespace = "tv.orbit.classic"
compileSdk = 36
@@ -308,6 +308,24 @@ internal data class PoolEpisode(val id: String, val sourceId: String, val mark:
* In a block's group. A film can belong to more than one, written "late+day": a film the Director's Chair moved into daytime
* with your approval keeps its place at night too (Paul, 18 November 2026).
*/
/**
* A title you approved without naming a block (the Director's Chair, the Stage 3 replacements). On a channel whose every hour
* belongs to a named block, it joins each everyday block, except one kept on equal turns (Tots' Wind Down), so it actually airs
* (23 November 2026: Terra's Blue Planet III and Africa, approved weeks before, had never been on). Where a channel has an open
* everyday block it plays there, as before.
*/
internal const val OPEN_GROUP = "*"
internal fun openJoins(part: DayPart, parts: List<DayPart>) = part.days.isEmpty() && part.weighted &&
parts.none { p -> p.days.isEmpty() && p.titles.isEmpty() && p.group.isEmpty() }
/** [pool] with the titles approved without a block marked [OPEN_GROUP], by item or by name (an approval waiting to be found again). */
internal fun withOpenApprovals(pool: List<PoolSeries>, choices: ChannelChoices): List<PoolSeries> {
val open = choices.accepted.filter { it.group.isEmpty() }
if (open.isEmpty()) return pool
val ids = open.map { it.id }.toSet(); val keys = open.map { seriesKey(it.title) }.toSet()
return pool.map { if (it.group.isEmpty() && (it.id in ids || seriesKey(it.title) in keys)) it.copy(group = OPEN_GROUP) else it }
}
internal fun inGroup(series: PoolSeries, group: String) = group.isNotEmpty() && (series.group == group || group in series.group.split('+'))
internal data class PoolSeries(val id: String, val title: String, val episodes: List<PoolEpisode>, val group: String = "", val ref: String = "", val year: Int? = null) {
@@ -397,9 +415,11 @@ internal fun dayPartFor(pool: List<PoolSeries>, parts: List<DayPart>, startMs: L
if (part.titles.isEmpty() && part.group.isEmpty()) return Triple(pool, name, part)
val allowed = PartPools.of(pool, part) {
val titles = part.titles.map(::seriesKey).toSet()
// A film is named with its year, as "Halloween (1978)"; the pool already holds that exact film under its plain title.
val films = part.titles.map { seriesKey(FilmIdentity.of(it).title) }.toSet()
pool.filter { seriesKey(it.title) in titles || (it.isFilm && seriesKey(it.title) in films) || inGroup(it, part.group) }
// A film is named with its year, as "Halloween (1978)"; the pool already holds that exact film under its plain title,
// or with the year in its name, as the VPS names its events ("AEW All Out 2019" for "AEW All Out (2019)").
val films = part.titles.flatMap { FilmIdentity.of(it).let { f -> listOfNotNull(seriesKey(f.title), f.year?.let { y -> seriesKey("${f.title} $y") }) } }.toSet()
val open = openJoins(part, parts)
pool.filter { seriesKey(it.title) in titles || (it.isFilm && seriesKey(it.title) in films) || inGroup(it, part.group) || (open && it.group == OPEN_GROUP) }
}
if (allowed.isNotEmpty()) return Triple(allowed, name, part)
}
@@ -422,7 +422,7 @@ internal class ChannelScheduler(private val store: ScheduleStore,
// Under the plan lock, so a programme being re-timed for its real length (PlanEdits) is never written over.
val (existing, plan) = synchronized(PlanEdits.lock) {
val existing = store.loadPlan(userId, number)
val plan = topUpPlan(existing, base, pool?.series?.let { withoutFailed(it, store.loadFailed(userId)) }?.let { if (programming.mixedTurns) mixedTurnOrder(it, number) else it }, now, programming.filmRestMs, programming.finishTogether, programming.dayParts,
val plan = topUpPlan(existing, base, pool?.series?.let { withOpenApprovals(withoutFailed(it, store.loadFailed(userId)), choices) }?.let { if (programming.mixedTurns) mixedTurnOrder(it, number) else it }, 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, fileRestMs = programming.fileRestMs, stories = programming.storyGrouping, shorts = programming.shorts, marathon = programming.marathon,
seasonEndMs = seasonEndMs(number, now), network = network) ?: throw EmbyCheckException("${programming.name} has no episodes to schedule.")
@@ -0,0 +1,47 @@
package tv.orbit.classic
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
/** Approvals without a block air on channels whose every hour is a named block (23 November 2026: Terra's Blue Planet III). */
class OpenApprovalsTest {
private val zone = java.time.ZoneOffset.UTC
private fun at(day: Int, hour: Int) = java.time.LocalDateTime.of(2026, 11, day, hour, 0).toInstant(zone).toEpochMilli() // 23rd is a Monday
private fun show(id: String, title: String) = PoolSeries(id, title, listOf(PoolEpisode("$id-1", "x", EpisodeMark(1, 1), "Ep", 30 * 60_000L), PoolEpisode("$id-2", "x", EpisodeMark(1, 2), "Ep", 30 * 60_000L)))
private fun film(id: String, title: String) = PoolSeries(id, title, listOf(PoolEpisode(id, "x", EpisodeMark(1, 1), title, 120 * 60_000L)))
private val parts = listOf(
DayPart(19, 20, listOf("AEW All Out (2019)"), days = setOf(java.time.DayOfWeek.SUNDAY), onTime = true, once = true),
DayPart(6, 18, listOf("Day Show")), DayPart(18, 21, listOf("Calm Show"), weighted = false), DayPart(21, 6, listOf("Late Show")))
@Test fun anApprovalWithoutABlockJoinsEveryEverydayBlockButTheCalmOne() {
val approved = show("a1", "Blue Planet III")
val pool = withOpenApprovals(listOf(show("d", "Day Show"), show("c", "Calm Show"), show("l", "Late Show"), approved),
ChannelChoices(listOf(Suggestion("a1", "Blue Planet III", 2023, "Series", "", "Placed by you"))))
fun ids(hour: Int) = dayPartFor(pool, parts, at(23, hour), zone).first.map { it.id }.toSet()
assertEquals(setOf("d", "a1"), ids(10))
assertEquals(setOf("c"), ids(19))
assertEquals(setOf("l", "a1"), ids(23))
}
@Test fun aChannelWithAnOpenBlockKeepsItsApprovalsThere() {
val open = listOf(DayPart(5, 21, listOf("Day Show")), DayPart(21, 5))
val pool = withOpenApprovals(listOf(show("d", "Day Show"), show("a1", "Approved")), ChannelChoices(listOf(Suggestion("a1", "Approved", null, "Series", "", "x"))))
assertEquals(setOf("d"), dayPartFor(pool, open, at(23, 10), zone).first.map { it.id }.toSet())
assertTrue("a1" in dayPartFor(pool, open, at(23, 22), zone).first.map { it.id })
}
@Test fun aPresetTitleOrAGroupedApprovalIsLeftAsItIs() {
val pool = withOpenApprovals(listOf(show("d", "Day Show"), show("g", "Grouped")), ChannelChoices(listOf(Suggestion("g", "Grouped", null, "Series", "late", "x"))))
assertTrue(pool.none { it.group == OPEN_GROUP })
}
@Test fun anEventNamedWithItsYearFindsTheLibrarysNameWithTheYearInIt() {
val ppv = film("p1", "AEW All Out 2019")
val chosen = dayPartFor(listOf(show("d", "Day Show"), ppv), parts, at(29, 19), zone)
assertEquals(listOf("p1"), chosen.first.map { it.id })
assertTrue(chosen.second.startsWith("event"))
assertFalse(openJoins(parts[0], parts))
}
}