diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 66dc8114..57e9106d 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -10,7 +10,7 @@ android { minSdk = 26 targetSdk = 36 versionCode = 244 - versionName = "0.108.84-smart-setup" + versionName = "0.108.84-your-chair" } buildFeatures { compose = true } // The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so diff --git a/android/app/src/main/java/tv/orbit/classic/DirectorChair.kt b/android/app/src/main/java/tv/orbit/classic/DirectorChair.kt index c8877b54..674cec60 100644 --- a/android/app/src/main/java/tv/orbit/classic/DirectorChair.kt +++ b/android/app/src/main/java/tv/orbit/classic/DirectorChair.kt @@ -316,8 +316,10 @@ private val DirectorLock = Any() */ internal fun directorReports(store: ScheduleStore, catalogue: CatalogueStore, userId: String, nowMs: Long = System.currentTimeMillis()): Map? = synchronized(DirectorLock) { val evidence = store.evidenceFile(); val collections = store.collectionsFile(); val cache = store.directorFile(); val decisions = store.decisionsFile() + // Your channels join the Chair with their own shows as their identity. + YourBriefs = CustomChannels.list.mapNotNull { c -> runCatching { yourBrief(c.number, c.name, catalogue.shapeRows(store.loadChoices(userId, c.number).accepted.map { it.id })) }.getOrNull() } val key = listOf(evidence.lastModified(), collections.lastModified(), store.poolsStamp(), catalogue.summary().total ?: 0L, decisions.lastModified(), - store.learningFile().lastModified(), store.eventIdeasFile().lastModified()).joinToString(":") + store.learningFile().lastModified(), store.eventIdeasFile().lastModified(), YourBriefs.joinToString("|") { "${it.number}${it.genresAny.sorted()}${it.era}" }.hashCode()).joinToString(":") runCatching { JSONObject(cache.readText()) }.getOrNull()?.takeIf { it.optString("key") == key && nowMs - it.optLong("savedMs") < 24 * 60 * 60_000L }?.let { saved -> val reports = saved.optJSONObject("reports") if (reports != null) return@synchronized DirectorMode.values().associateWith { DeskReport.of(reports.getJSONObject(it.name)) } diff --git a/android/app/src/main/java/tv/orbit/classic/DirectorScoring.kt b/android/app/src/main/java/tv/orbit/classic/DirectorScoring.kt index 2a0e3620..9469a6d5 100644 --- a/android/app/src/main/java/tv/orbit/classic/DirectorScoring.kt +++ b/android/app/src/main/java/tv/orbit/classic/DirectorScoring.kt @@ -18,8 +18,16 @@ internal class Brief(val number: Int, val name: String, val kinds: Set, private fun w(vararg words: String) = Regex("\\b(" + words.joinToString("|") + ")", RegexOption.IGNORE_CASE) +/** Every channel the Chair places titles on: Orbit's own, then the channels you've made ([YourBriefs]). */ +internal val Briefs: List get() = BaseBriefs + YourBriefs +/** + * Channels of your own as the Chair sees them (Paul, 7 November 2026: the same few strong picks for your channels, matched + * to each one's identity). Worked out from each channel's own shows when the Chair's report is made; see [yourBrief]. + */ +@Volatile internal var YourBriefs: List = emptyList() + /** The briefs, in the reference's order (ties keep this order). */ -internal val Briefs: List = listOf( +internal val BaseBriefs: List = listOf( Brief(101, "Orbit 1", setOf("Series"), setOf("Comedy"), themes = w("sitcom", "family", "household", "neighbou?r", "roommate", "parents", "dad", "mum", "mom", "sisters", "brothers", "college", "workplace"), against = w("murder", "killer", "documentary", "wedding of", "engagement"), era = 1970 to 2026, needTheme = true), Brief(102, "Orbit 2", setOf("Series"), setOf("Game Show", "Reality", "Comedy", "Talk"), themes = w("quiz", "game show", "contestants", "panel", "challenge", "teams compete"), @@ -202,7 +210,7 @@ internal fun channelScore(e: TitleEvidence, b: Brief, text: ChannelText, links: if (b.kids && rating in Adult) return 0.0 to listOf("rated $rating") var s = 0.0 val animated = "Animation" in g; val doc = "Documentary" in g - if (animated && ch !in AnimatedChannels) return 0.0 to listOf("animation, not for this channel") + if (animated && ch !in AnimatedChannels && ch !in YOURS_FIRST..YOURS_LAST) return 0.0 to listOf("animation, not for this channel") if (!animated && ch in AnimatedChannels && g.isNotEmpty() && ch != 611 && ch != 601) return 0.0 to listOf("live action, not for this channel") if (doc && ch in FictionChannels) return 0.0 to listOf("a documentary, not fiction") if (g.isNotEmpty() && !doc && ch in FactualChannels && ch != 401 && !("Reality" in g && (ch == 203 || ch == 204))) return 0.0 to listOf("fiction, not factual") diff --git a/android/app/src/main/java/tv/orbit/classic/SmartSetup.kt b/android/app/src/main/java/tv/orbit/classic/SmartSetup.kt index cd5ef5e3..593296fb 100644 --- a/android/app/src/main/java/tv/orbit/classic/SmartSetup.kt +++ b/android/app/src/main/java/tv/orbit/classic/SmartSetup.kt @@ -107,3 +107,19 @@ internal fun titlesCarriedBy(picks: Map, channels: Collection): Brief? { + if (rows.isEmpty()) return null + val counts = rows.flatMap { it.genres }.groupingBy { it }.eachCount() + val common = counts.filter { it.value >= rows.size * .3 }.entries.sortedByDescending { it.value }.take(4).map { it.key }.toSet() + val must = counts.filter { it.value >= rows.size * .8 }.keys.take(1).toSet() + val years = rows.mapNotNull { it.year } + val never = Regex("(?!)") + return Brief(number, name, rows.map { it.type }.toSet(), common.ifEmpty { counts.keys.take(4).toSet() }, must, never, never, + (years.minOrNull() ?: 1900) - 5 to (years.maxOrNull() ?: 2030) + 5, kids = rows.all { it.rating in KidsOk }) +} diff --git a/android/app/src/test/java/tv/orbit/classic/SmartSetupTest.kt b/android/app/src/test/java/tv/orbit/classic/SmartSetupTest.kt index c9fd5e23..2205dca1 100644 --- a/android/app/src/test/java/tv/orbit/classic/SmartSetupTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/SmartSetupTest.kt @@ -69,4 +69,18 @@ class SmartSetupTest { assertTrue(weekLine(200 * hour).contains("more than a week")) assertTrue(weekLine(42 * hour, hoursPerDay = 6).contains("more than a week")) // an evenings-only channel goes further } + + @Test fun yourChannelsJoinTheChairWithTheirOwnShowsAsTheirIdentity() { + val rows = listOf(row("X-Files", "Series", "TV-14", "Science Fiction", "Mystery", "Drama", year = 1993), row("Millennium", "Series", "TV-14", "Mystery", "Crime", "Drama", year = 1996), + row("Twin Peaks", "Series", "TV-14", "Mystery", "Drama", year = 1990), row("Poltergeist", "Movie", "PG", "Horror", year = 1982)) + val brief = yourBrief(701, "The Unknown", rows)!! + assertEquals(setOf("Series", "Movie"), brief.kinds) + assertTrue("Mystery" in brief.genresAny); assertTrue("Drama" in brief.genresAny) + assertTrue(brief.needAny.isEmpty()) // no genre on every one of them + assertEquals(1977 to 2001, brief.era); assertFalse(brief.kids) + assertTrue(yourBrief(702, "Little Ones", listOf(row("Bluey", "Series", "TV-Y", "Animation")))!!.kids) + assertNull(yourBrief(703, "Empty", emptyList())) + val before = YourBriefs + try { YourBriefs = listOf(brief); assertTrue(Briefs.any { it.number == 701 }); assertTrue(Briefs.any { it.number == 101 }) } finally { YourBriefs = before } + } }