From 2db9068e89dd92133253365516b52030972d03b8 Mon Sep 17 00:00:00 2001 From: Pauljd Date: Sat, 7 Nov 2026 15:47:02 +0000 Subject: [PATCH] Big channels of your own: one series that fails to read is skipped, not the whole plan Sakura's first plan read 200 chosen series and a single slow answer failed it, switching the channel off. A chosen series whose read fails is now skipped this time (up to a tenth of them), and a switch-on failure is logged by kind. 0.108.95. Co-Authored-By: Claude Opus 5.5 (1M context) --- android/app/build.gradle.kts | 4 ++-- .../src/main/java/tv/orbit/classic/EmbyClient.kt | 4 ++-- .../java/tv/orbit/classic/EmbyConnectionScreen.kt | 6 ++++-- .../java/tv/orbit/classic/EmbyPlaybackProtocol.kt | 13 ++++++++++++- .../java/tv/orbit/classic/SecureMediaDataSource.kt | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 1568ea0b..aa96cc94 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 = 254 - versionName = "0.108.94-catch-up-v2" + versionCode = 255 + versionName = "0.108.95-sakura-reads" } buildFeatures { compose = true } // The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so 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 ee1ff3bb..bb283a41 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt @@ -62,9 +62,9 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI } /** The sign-in headers for this kind of server. */ internal fun authHeaders(token: String?): Map = when (kind) { - ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.94\"") + + ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.95\"") + (token?.let { mapOf("X-Emby-Token" to it) } ?: emptyMap()) - ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.94\"" + + ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.95\"" + (token?.let { ", Token=\"$it\"" } ?: "")) } /** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */ diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt index 703a1f1e..d44393f9 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt @@ -552,8 +552,10 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea message = "${programming.name} is off, and back to a short repeat. Its schedule and place are kept." } } catch (cancelled: CancellationException) { throw cancelled } - catch (failure: EmbyCheckException) { withContext(Dispatchers.IO) { scheduler.setEnabled(active.accountId, programming.number, false) }; message = failure.message } - catch (_: Exception) { withContext(Dispatchers.IO) { scheduler.setEnabled(active.accountId, programming.number, false) }; message = "${programming.name} could not be scheduled, so it stays off." } + catch (failure: EmbyCheckException) { withContext(Dispatchers.IO) { scheduler.setEnabled(active.accountId, programming.number, false) }; message = failure.message + android.util.Log.w("OrbitSchedule", "channel=${programming.number} switchOn failed=${failure.javaClass.simpleName} status=${failure.httpStatus}") } + catch (failure: Exception) { withContext(Dispatchers.IO) { scheduler.setEnabled(active.accountId, programming.number, false) }; message = "${programming.name} could not be scheduled, so it stays off." + android.util.Log.w("OrbitSchedule", "channel=${programming.number} switchOn failed=${failure.javaClass.simpleName}") } finally { busy = false; CustomChannels.planning = null } } } 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 6ff2ae79..06734805 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt @@ -392,6 +392,9 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v val film = lookup.film ?: continue if (pool.none { it.id == film.id }) pool += film } + // One slow or failing series among many chosen (Sakura's 200, 7 November 2026) is skipped this time rather than failing + // the whole read; it's tried again at the next refresh. A provider that keeps failing still stops the read. + var skipped = 0 for (accepted in choices.accepted) { checkActive() if (pool.any { it.id == accepted.id || seriesKey(it.title) == seriesKey(accepted.title) }) continue @@ -401,7 +404,15 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v else { requests++; playableFilm(accepted.id, programming.englishAudio) ?: continue } pool += PoolSeries(accepted.id, accepted.title, listOf(PoolEpisode(accepted.id, source, EpisodeMark(1, 1), accepted.title, duration)), accepted.group) } else { - val whole = readWholeSeries(transport, userId, ::currentToken, SeriesCandidate(accepted.id, accepted.title, accepted.year, ""), checkActive, onRequest = { requests++ }, canDecode = BoxDecoders::canDecode, englishAudio = programming.englishAudio) + val whole = try { readWholeSeries(transport, userId, ::currentToken, SeriesCandidate(accepted.id, accepted.title, accepted.year, ""), checkActive, onRequest = { requests++ }, canDecode = BoxDecoders::canDecode, englishAudio = programming.englishAudio) } + catch (failure: Exception) { + // Signed out, cancelled, or too many: stop. Anything else about one series: skip it this time. + val status = (failure as? EmbyCheckException)?.httpStatus + if (failure is kotlinx.coroutines.CancellationException || failure is InterruptedException || status == 401 || status == 403 || + ++skipped > maxOf(MAX_FAILED_READS, choices.accepted.size / 10)) throw failure + android.util.Log.w("OrbitSchedule", "channel=${programming.number} chosen read skipped=$skipped failed=${failure.javaClass.simpleName} status=$status") + continue + } if (whole.episodes.isNotEmpty()) pool += whole.copy(group = accepted.group) } } 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 dda5a77e..bba2372a 100644 --- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt +++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt @@ -39,7 +39,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.108.94") + next.setRequestProperty("User-Agent", "OrbitTV/0.108.95") 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()) {