Inspect hook: log each episode's cast for the anthology check (read only, local log)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m4s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m29s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-04 21:52:43 +00:00
co-authored by Claude Opus 5.5
parent effb42b6c6
commit be0772ac9c
@@ -191,11 +191,19 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
* Read-only: what the library holds for one series, episode by episode, for checking how a show is stored before
* scheduling it. Names, numbers, runtimes, sources and chapter names; no file paths.
*/
/** An episode's cast for the anthology check (Paul approved these inspections, 4 November 2026): up to 16 names with their roles, to the local log only. */
private fun castLine(episode: JSONObject): String {
val people = episode.optJSONArray("People")
val cast = (0 until minOf(people?.length() ?: 0, 16)).mapNotNull { people!!.optJSONObject(it) }
.joinToString("|") { "${EmbyClient.clean(it.optString("Name"), 40)}:${EmbyClient.clean(it.optString("Type"), 12)}" }
return "inspect cast=${people?.length() ?: 0} [$cast]"
}
fun inspectSeries(title: String, failed: Set<String> = emptySet()): List<String> {
val match = searchSeries(transport, userId, ::currentToken, title).candidates.filter { seriesKey(it.title) == seriesKey(title) }
if (match.isEmpty()) return listOf("inspect \"$title\": no series of that name")
return match.flatMap { series ->
val reply = transport.execute(EmbyRequest("GET", "/Shows/${series.id}/Episodes?UserId=$userId&StartIndex=0&Limit=100&Fields=MediaSources,Chapters&EnableImages=false&EnableUserData=false",
val reply = transport.execute(EmbyRequest("GET", "/Shows/${series.id}/Episodes?UserId=$userId&StartIndex=0&Limit=100&Fields=MediaSources,Chapters,People&EnableImages=false&EnableUserData=false",
token = currentToken(), readTimeoutMs = WHOLE_SERIES_TIMEOUT_MS))
EmbyClient.expectSuccess(reply.status, false)
val body = EmbyClient.parse(reply.body)
@@ -211,7 +219,8 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
val chapterNames = (0 until minOf(chapters?.length() ?: 0, 12)).joinToString("|") { EmbyClient.clean(chapters!!.optJSONObject(it)?.optString("Name").orEmpty(), 30) }
listOf("inspect S${e.optInt("ParentIndexNumber", -1)}E${e.optInt("IndexNumber", -1)} id=${e.optString("Id").takeIf(EmbyClient::validId) ?: "invalid"} type=${e.optString("Type")} location=${safeContainerLabel(e.optString("LocationType"))} min=${e.optLong("RunTimeTicks", 0) / 600_000_000} sources=${sources?.length() ?: 0}" +
" containers=${(0 until (sources?.length() ?: 0)).joinToString(",") { safeContainerLabel(sources!!.optJSONObject(it)?.optString("Container").orEmpty()) }} chapters=${chapters?.length() ?: 0} [$chapterNames] name=\"${EmbyClient.clean(e.optString("Name"), 80)}\"") +
(0 until minOf(sources?.length() ?: 0, 8)).mapNotNull { sources!!.optJSONObject(it) }.map { describeSource(it, e.optLong("RunTimeTicks", 0), BoxDecoders::canDecode, BoxDecoders::has, e.optString("Id") in failed) }
(0 until minOf(sources?.length() ?: 0, 8)).mapNotNull { sources!!.optJSONObject(it) }.map { describeSource(it, e.optLong("RunTimeTicks", 0), BoxDecoders::canDecode, BoxDecoders::has, e.optString("Id") in failed) } +
castLine(e)
}
}
}