Leave out files the box can't decode, and remember ones that fail (0.61.0)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m10s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m27s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-02 10:29:35 +00:00
co-authored by Claude Opus 5.5
parent 10424d3633
commit 5dece25a6a
16 changed files with 171 additions and 33 deletions
@@ -481,4 +481,44 @@ class ChannelScheduleTest {
val cells = guideCells(channel, start, start + 120 * minute)
assertEquals(cells.drop(1), guideWatchableCells(cells, now).drop(1))
}
private fun withVideo(id: String, number: Int, codec: String?) = episode(id, 1, number).also { row ->
val source = row.getJSONArray("MediaSources").getJSONObject(0)
if (codec != null) source.put("MediaStreams", JSONArray().put(JSONObject().put("Type", "Audio").put("Codec", "aac")).put(JSONObject().put("Type", "Video").put("Codec", codec)))
}
@Test fun episodesTheBoxCantDecodeAreLeftOut() {
val rows = JSONArray().put(withVideo("good", 1, "h264")).put(withVideo("bad", 2, "wmv3")).put(withVideo("unknown", 3, null))
val transport = EmbyTransport { EmbyReply(200, JSONObject().put("Items", rows).put("TotalRecordCount", rows.length()).toString()) }
val result = readWholeSeries(transport, user, { "t" }, series, canDecode = { it != "wmv3" })
assertEquals(listOf("good", "unknown"), result.episodes.map { it.id })
}
@Test fun formatNamesMapToDecoders() {
assertEquals("video/avc", videoMimeFor("H264"))
assertEquals("video/mp4v-es", videoMimeFor("mpeg4"))
assertNull(videoMimeFor("something-new"))
}
@Test fun aFailedFileIsLeftOutFromThenOn() {
val store = store()
store.saveFailed(user, setOf("a-1-1"))
val left = withoutFailed(pool, store.loadFailed(user))
assertFalse(left.flatMap { it.episodes }.any { it.id == "a-1-1" })
assertEquals(pool.size, left.size)
assertEquals(pool, withoutFailed(pool, emptySet()))
}
@Test fun aShowWithNothingLeftDropsOut() {
val only = listOf(show("z", 1, 1), show("y", 1, 1))
assertEquals(listOf("y"), withoutFailed(only, setOf("z-1-1")).map { it.id })
}
@Test fun failedFilesSurviveAndAreEmptyByDefault() {
val store = store()
assertTrue(store.loadFailed(user).isEmpty())
store.saveFailed(user, setOf("a"))
store.saveFailed(user, store.loadFailed(user) + "b")
assertEquals(setOf("a", "b"), store.loadFailed(user))
}
}