From f8d172e341222e476ee01c8d2492344c5e75d2ee Mon Sep 17 00:00:00 2001 From: Pauljd Date: Mon, 30 Nov 2026 07:35:56 +0000 Subject: [PATCH] Report of list titles missing from the library (env-gated, read-only) Co-Authored-By: Claude Opus 5.5 --- .../orbit/classic/MissingTitlesReportTest.kt | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 android/app/src/test/java/tv/orbit/classic/MissingTitlesReportTest.kt diff --git a/android/app/src/test/java/tv/orbit/classic/MissingTitlesReportTest.kt b/android/app/src/test/java/tv/orbit/classic/MissingTitlesReportTest.kt new file mode 100644 index 00000000..366b26f3 --- /dev/null +++ b/android/app/src/test/java/tv/orbit/classic/MissingTitlesReportTest.kt @@ -0,0 +1,41 @@ +package tv.orbit.classic + +import org.junit.Assume.assumeTrue +import org.junit.Test +import java.io.File + +/** + * Titles the channels' lists name that the library doesn't have (Paul, 26 November 2026: what to request). Read-only: matched + * against the catalogue export (SIM_CATALOGUE) by the same names and years the refresh uses. Writes SIM_OUT/missing.tsv. + */ +class MissingTitlesReportTest { + @Test fun report() { + val cat = System.getenv("SIM_CATALOGUE")?.let(::File) + assumeTrue(cat != null && cat.exists()) + val rows = cat!!.readLines().map { it.split('\t') }.filter { it.size >= 5 } + val films = rows.filter { it[1] == "Movie" }.groupBy { seriesKey(it[2]) } + val series = rows.filter { it[1] == "Series" }.map { seriesKey(it[2]) } + val seriesSet = series.toSet() + val out = StringBuilder("channel\tname\tkind\tentry\treason\n") + for (p in BuiltInChannels) { + val choices = ChannelChoices() + for (e in refreshEntries(p, choices)) { + val reason = when (e.kind) { + RefreshEntry.Kind.FILM -> { + val id = FilmIdentity.of(e.text); val named = films[seriesKey(id.title)].orEmpty() + when { + named.isEmpty() -> "not in library" + id.imdb != null && named.none { it[4].equals(id.imdb, true) } && id.year != null && named.none { it[3].toIntOrNull()?.let { y -> kotlin.math.abs(y - id.year) <= 1 } == true } -> "only other films of that name" + id.year != null && named.none { it[3].toIntOrNull()?.let { y -> kotlin.math.abs(y - id.year) <= 1 } == true } && named.none { id.imdb != null && it[4].equals(id.imdb, true) } -> "only other years: " + named.mapNotNull { it[3].ifEmpty { null } }.distinct().joinToString(",") + else -> null + } + } + RefreshEntry.Kind.SERIES -> { val k = seriesKey(e.text); if (k in seriesSet || series.any { it.startsWith("$k ") }) null else "not in library" } + else -> null + } ?: continue + out.append("${p.number}\t${p.name}\t${e.kind}\t${e.text}\t$reason\n") + } + } + File(System.getenv("SIM_OUT")!!).also { it.mkdirs() }.resolve("missing.tsv").writeText(out.toString()) + } +}