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) <noreply@anthropic.com>
This commit is contained in:
2026-11-07 15:47:02 +00:00
co-authored by Claude Opus 5.5
parent af2c78de73
commit 2db9068e89
5 changed files with 21 additions and 8 deletions
+2 -2
View File
@@ -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
@@ -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<String, String> = 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. */
@@ -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 }
}
}
@@ -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)
}
}
@@ -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()) {