0.91.1: read-only series inspection for The Last Drive-In
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m55s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m28s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-03 14:54:36 +00:00
co-authored by Claude Opus 5.5
parent f1e853576f
commit 1449628890
7 changed files with 38 additions and 4 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 111
versionName = "0.91.0-film-nights"
versionCode = 112
versionName = "0.91.1-film-nights"
}
buildFeatures { compose = true }
compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 }
@@ -77,6 +77,7 @@ internal class ChannelScheduler(private val store: ScheduleStore, private val cl
* A failed refresh keeps what's there, so a provider outage can't disturb what's committed.
*/
fun topUp(session: EmbySampleSession, userId: String, programming: ChannelProgramming, loop: SampleChannel, checkActive: () -> Unit = {}): SchedulerReport {
SeriesInspection.take()?.let { title -> runCatching { session.inspectSeries(title) }.getOrElse { listOf("inspect failed: ${it.javaClass.simpleName}") }.forEach { Log.i("OrbitSchedule", it) } }
val number = programming.number
val now = clock()
val cached = store.loadPool(userId, number)
@@ -120,3 +121,9 @@ internal class ChannelScheduler(private val store: ScheduleStore, private val cl
return report
}
}
/** Set from adb with --es orbit_inspect_series "Title", read once by the next top-up. For checking a show's episodes before it's scheduled. */
internal object SeriesInspection {
@Volatile var title: String? = null
fun take(): String? = title.also { title = null }
}
@@ -66,7 +66,7 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
connection.connectTimeout = 10_000
connection.readTimeout = request.readTimeoutMs ?: if (request.path == "/Sessions/Logout") 5_000 else 15_000
connection.setRequestProperty("Accept", "application/json")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.91.0\"")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.91.1\"")
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
if (request.method == "POST") {
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
@@ -187,6 +187,29 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
return PresetBuild(SampleChannel(media, preset.name, preset.number), groups.map { it.series.title }, missing)
}
/**
* 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.
*/
fun inspectSeries(title: String): 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=200&Fields=MediaSources,Chapters&EnableImages=false&EnableUserData=false",
token = currentToken(), readTimeoutMs = WHOLE_SERIES_TIMEOUT_MS))
EmbyClient.expectSuccess(reply.status, false)
val body = EmbyClient.parse(reply.body)
val rows = body.optJSONArray("Items") ?: return@flatMap listOf("inspect series=${series.id}: no episode list")
listOf("inspect series=${series.id} year=${series.year} episodes=${body.optInt("TotalRecordCount", rows.length())}") + (0 until rows.length()).mapNotNull { rows.optJSONObject(it) }.map { e ->
val sources = e.optJSONArray("MediaSources")
val chapters = e.optJSONArray("Chapters")
val chapterNames = (0 until minOf(chapters?.length() ?: 0, 12)).joinToString("|") { EmbyClient.clean(chapters!!.optJSONObject(it)?.optString("Name").orEmpty(), 30) }
"inspect S${e.optInt("ParentIndexNumber", -1)}E${e.optInt("IndexNumber", -1)} type=${e.optString("Type")} min=${e.optLong("RunTimeTicks", 0) / 600_000_000} sources=${sources?.length() ?: 0}" +
" containers=${(0 until (sources?.length() ?: 0)).joinToString(",") { sources!!.optJSONObject(it)?.optString("Container").orEmpty() }} chapters=${chapters?.length() ?: 0} [$chapterNames] name=\"${EmbyClient.clean(e.optString("Name"), 80)}\""
}
}
}
internal class PoolRead(val series: List<PoolSeries>, val requests: Int)
/** The first shows in the channel's list that have episodes to schedule. */
fun readChannelPool(programming: ChannelProgramming, loop: SampleChannel?, choices: ChannelChoices = ChannelChoices(), checkActive: () -> Unit = {}): PoolRead {
@@ -51,6 +51,7 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
if (intent?.getBooleanExtra("orbit_intro_test", false) == true) IntroTrial.nextTune = true
intent?.getStringExtra("orbit_inspect_series")?.take(120)?.let { SeriesInspection.title = it }
// One typeface everywhere, matching the channel logos.
setContent { MaterialTheme { CompositionLocalProvider(androidx.tv.material3.LocalTextStyle provides androidx.compose.ui.text.TextStyle(fontFamily = Barlow)) { OrbitApp() } } }
}
@@ -33,7 +33,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
next.instanceFollowRedirects = false
next.connectTimeout = 10_000
next.readTimeout = 20_000
next.setRequestProperty("User-Agent", "OrbitTV/0.91.0")
next.setRequestProperty("User-Agent", "OrbitTV/0.91.1")
next.setRequestProperty("Accept-Encoding", "identity")
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {
+3
View File
@@ -18,3 +18,6 @@ Four weeks of hourly top-ups from the box's real files after 0.90.0, with the ev
- Not checked here: whether each new film's copy plays on the box. That shows in the log when the box first reads them.
Unit tests: 345 passed. Lint passed. Not installed.
## 0.91.1
0.91.0 plus one read-only diagnostic: started from adb with --es orbit_inspect_series "Title", the next top-up logs that series' episodes (season, number, runtime, sources, containers, chapter names; no file paths). Used to check how The Last Drive-In is stored before any engine change. Nothing else differs.