From 14496288909a4db02c2d405218338048f9625aae Mon Sep 17 00:00:00 2001 From: Pauljd Date: Tue, 3 Nov 2026 14:54:36 +0000 Subject: [PATCH] 0.91.1: read-only series inspection for The Last Drive-In Co-Authored-By: Claude Opus 5.5 (1M context) --- android/app/build.gradle.kts | 4 ++-- .../java/tv/orbit/classic/ChannelScheduler.kt | 7 ++++++ .../main/java/tv/orbit/classic/EmbyClient.kt | 2 +- .../tv/orbit/classic/EmbyPlaybackProtocol.kt | 23 +++++++++++++++++++ .../java/tv/orbit/classic/MainActivity.kt | 1 + .../tv/orbit/classic/SecureMediaDataSource.kt | 2 +- docs/VERIFICATION-0.91.0.md | 3 +++ 7 files changed, 38 insertions(+), 4 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 147ec9ee..a2347fdd 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -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 } diff --git a/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt b/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt index 79c02105..6497fd8e 100644 --- a/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt +++ b/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt @@ -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 } +} diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt index 4d908a3b..00a2dfe8 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt @@ -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) diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt index bee4cd24..9a99486d 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt @@ -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 { + 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, 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 { diff --git a/android/app/src/main/java/tv/orbit/classic/MainActivity.kt b/android/app/src/main/java/tv/orbit/classic/MainActivity.kt index 2666e3ff..aa7880a3 100644 --- a/android/app/src/main/java/tv/orbit/classic/MainActivity.kt +++ b/android/app/src/main/java/tv/orbit/classic/MainActivity.kt @@ -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() } } } } diff --git a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt index 44a3eb11..ae4ba2d6 100644 --- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt +++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt @@ -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()) { diff --git a/docs/VERIFICATION-0.91.0.md b/docs/VERIFICATION-0.91.0.md index 6bbca0cb..10d267e8 100644 --- a/docs/VERIFICATION-0.91.0.md +++ b/docs/VERIFICATION-0.91.0.md @@ -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.