diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 44843348..52567744 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -3,7 +3,7 @@ plugins { id("org.jetbrains.kotlin.plugin.compose") } /** The release's build number: versionCode is this x 10 plus the edition's channel. */ -val ORBIT_BUILD = 68 +val ORBIT_BUILD = 69 android { namespace = "tv.orbit.classic" compileSdk = 36 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 548116c6..e11a5aa3 100644 --- a/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt +++ b/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt @@ -379,12 +379,15 @@ internal class ChannelScheduler(private val store: ScheduleStore, if (routine) lastRoutineRefreshMs = now val started = android.os.SystemClock.elapsedRealtime() try { - val read = session.readChannelPool(programming, loop, choices, checkActive, previous = cached?.series) + // Due only for approvals still waiting: those alone are read, and the rest of the pool stays as it is. + val onlyWaiting = waiting && cached != null && cached.signature == signature && !poolRefreshDue(cached.fetchedAtMs, number, now) + val read = session.readChannelPool(programming, loop, choices, checkActive, previous = cached?.series, waitingOnly = onlyWaiting) requests = read.requests fetchMs = android.os.SystemClock.elapsedRealtime() - started if (read.series.isNotEmpty()) { // A refresh that had to keep a few previous copies is tried again in a few hours rather than a week. - val fetched = if (read.carried > 0) now - POOL_REFRESH_MS + PARTIAL_POOL_RETRY_MS else now + // A read only for waiting approvals leaves the list's own refresh where it was. + val fetched = if (onlyWaiting) cached!!.fetchedAtMs else if (read.carried > 0) now - POOL_REFRESH_MS + PARTIAL_POOL_RETRY_MS else now if (read.carried > 0) Log.w("OrbitSchedule", "channel=$number poolRefreshPartial carried=${read.carried}") val signed = keepRefound(userId, programming, read) pool = ScheduleStore.SavedPool(read.series, fetched, signed) 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 cb9bc55b..6b7bcab8 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt @@ -378,10 +378,17 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v /** The first shows in the channel's list that have episodes to schedule. */ fun readChannelPool(programming: ChannelProgramming, loop: SampleChannel?, choices: ChannelChoices = ChannelChoices(), checkActive: () -> Unit = {}, /** The pool being refreshed, so one show whose read fails can keep its copy rather than losing the whole refresh. */ - previous: List? = null): PoolRead { + previous: List? = null, + /** + * Only the approvals still waiting to be found (22 November 2026): the rest of the pool is kept as it is, so a read + * that's only for them costs about a request each, not a whole list's search (After Dark's 180) every time. + */ + waitingOnly: Boolean = false): PoolRead { var requests = 0 val pool = mutableListOf() val partial = PartialRead(previous) + if (waitingOnly && previous != null) pool += previous + if (!(waitingOnly && previous != null)) { if (programming.filmRestMs != null) { // Films already in this channel's old line-up stay in it, unless the list now names another film of that title. val listed = programming.searches.map { seriesKey(FilmIdentity.of(it).title) }.toSet() @@ -461,6 +468,7 @@ 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 diff --git a/android/app/src/test/java/tv/orbit/classic/RefiledTest.kt b/android/app/src/test/java/tv/orbit/classic/RefiledTest.kt index 04fad97e..1bbf9b1d 100644 --- a/android/app/src/test/java/tv/orbit/classic/RefiledTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/RefiledTest.kt @@ -365,4 +365,16 @@ class WaitingApprovalsTest { assertEquals(setOf("new1", "new2", "new3"), store.loadPool(user, 701)!!.series.map { it.id }.toSet()) dir.deleteRecursively() } + + @Test fun aReadOnlyForWaitingApprovalsSearchesNothingElse() { + val asked = mutableListOf() + val inner = transport { true } + val session = EmbySampleSession(EmbyTransport { r -> asked += r.path; inner.execute(r) }, "fixture-token-private", user, EmbySample(emptyList(), 0)) + val listed = ChannelProgramming(305, "After Dark", listOf("Some Film (1980)", "Another Film (1981)"), filmRestMs = 1L) + val kept = listOf(PoolSeries("k1", "Some Film", listOf(PoolEpisode("k1", "s1", EpisodeMark(1, 1), "Some Film", 5_400_000L)))) + val read = session.readChannelPool(listed, null, approvals, previous = kept, waitingOnly = true) + assertTrue(asked.none { "SearchTerm" in it }) // the list isn't searched again + assertEquals(setOf("k1", "new1", "new2", "new3"), read.series.map { it.id }.toSet()) + assertEquals(3, asked.count { "AnyProviderIdEquals" in it }) + } }