Year and media type checked alongside the title on every repair and match (build 66)
release-gate / verify (push) Successful in 10m9s
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m54s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 3m29s

Paul, 18 November 2026: verify the year and media type too, especially for remakes. A provider-ID repair is refused
when its year differs from the approval's by more than one (release dates over New Year), whatever the name; with no
year, the name must fit; two works under one ID need the exact year. A saved film ID now holding a remake isn't trusted.
The server move does the same, and a film never matches a series of the same name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 15:04:18 +00:00
co-authored by Claude Opus 5.5
parent 224b10499a
commit fb6f68258d
5 changed files with 64 additions and 10 deletions
@@ -66,3 +66,36 @@ class IdRepairsTest {
@Test fun aDifferentFilmWithAnotherNameAndYearIsRefused() =
assertNull(pickByProvider(listOf(row("a", "Krull", 1983)), "Tremors", 1990))
}
/** Year and type alongside the title (Paul, 18 November 2026), so a remake is never taken for the original. */
class RemakeGuardTest {
private fun row(id: String, name: String, year: Int? = null) = JSONObject().put("Id", id).put("Name", name).apply { year?.let { put("ProductionYear", it) } }
@Test fun aRemakeWithTheSameNameIsRefusedByItsYear() =
assertNull(pickByProvider(listOf(row("a", "The Blob", 1988)), "The Blob", 1958))
@Test fun aReleaseDateStraddlingNewYearStillCounts() =
assertEquals("a", pickByProvider(listOf(row("a", "Nosferatu the Vampyre", 1979)), "Nosferatu the Vampyre", 1978)?.optString("Id"))
@Test fun withNoYearToCompareTheNameMustFit() {
assertNull(pickByProvider(listOf(row("a", "Krull")), "Tremors", null))
assertEquals("a", pickByProvider(listOf(row("a", "Tremors")), "Tremors", null)?.optString("Id"))
}
@Test fun twoWorksUnderOneIdNeedTheExactYear() =
assertNull(pickByProvider(listOf(row("a", "Halloween", 1978), row("b", "Halloween", 2018)), "Halloween", 1979))
@Test fun aSavedFilmIdNowHoldingTheRemakeIsntTrusted() {
val transport = EmbyTransport { r ->
if ("Ids=f1" in r.path) EmbyReply(200, JSONObject().put("Items", org.json.JSONArray().put(row("f1", "The Fog", 2005).put("Type", "Movie")
.put("MediaSources", org.json.JSONArray().put(JSONObject().put("Id", "s1").put("Container", "mkv").put("RunTimeTicks", 90 * 60_000L * 10_000))))).toString())
else EmbyReply(200, JSONObject().put("Items", org.json.JSONArray()).toString())
}
EmbyServer.origin = "https://emby.example.com"; IdRepairs.resetForTest()
try {
val s = EmbySampleSession(transport, "fixture-token-private", "fixture-user", EmbySample(emptyList(), 0))
val read = s.readChannelPool(ChannelProgramming(305, "After Dark", emptyList(), filmRestMs = 1L), null, ChannelChoices(listOf(Suggestion("f1", "The Fog", 1980, "Movie", "", ""))))
assertTrue(read.series.isEmpty())
} finally { EmbyServer.origin = ""; IdRepairs.resetForTest() }
}
}
@@ -41,6 +41,18 @@ class ServerMoveTest {
assertNull(m.newId); assertEquals(MoveHow.Missing, m.how)
}
@Test fun aRemakeCarryingTheOriginalsIdIsStillNotTaken() {
val old = MemoryMoveCatalogue(sequenceOf(film("1", "The Fog", 1980, "imdb" to "tt0080749")))
val new = MemoryMoveCatalogue(sequenceOf(film("2", "The Fog", 2005, "imdb" to "tt0080749")))
assertNull(MoveMatcher(old, new).match("1", "The Fog", "Movie", 1980).newId)
}
@Test fun aFilmAndASeriesWithOneNameNeverMatchEachOther() {
val old = MemoryMoveCatalogue(sequenceOf(film("1", "Fargo", 1996)))
val new = MemoryMoveCatalogue(sequenceOf(show("2", "Fargo", 1996)))
assertNull(MoveMatcher(old, new).match("1", "Fargo", "Movie", 1996).newId)
}
@Test fun noIdsAtAllFallsBackToTitleAndYear() {
val old = MemoryMoveCatalogue(sequenceOf(film("1", "Robin Redbreast", 1970)))
val new = MemoryMoveCatalogue(sequenceOf(film("2", "Robin Redbreast (1970)", 1970), film("3", "Robin Redbreast", 2020)))