From c5c556a05cbd2dc9ffa601ad8fb23ca6dd719525 Mon Sep 17 00:00:00 2001 From: Pauljd Date: Tue, 3 Nov 2026 11:56:28 +0000 Subject: [PATCH] 0.84.1: a show with several copies uses the one with the most playable episodes; Doctor Who (2024) joins Paradox's mix Co-Authored-By: Claude Opus 5.5 (1M context) --- android/app/build.gradle.kts | 2 +- .../java/tv/orbit/classic/ChannelSchedule.kt | 2 +- .../tv/orbit/classic/EmbyPlaybackProtocol.kt | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index a43f640a..2313e92a 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -10,7 +10,7 @@ android { minSdk = 26 targetSdk = 36 versionCode = 103 - versionName = "0.84.1-other-copies" + versionName = "0.84.1-fullest-copy" } buildFeatures { compose = true } compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 } diff --git a/android/app/src/main/java/tv/orbit/classic/ChannelSchedule.kt b/android/app/src/main/java/tv/orbit/classic/ChannelSchedule.kt index 378e7d8c..5760d791 100644 --- a/android/app/src/main/java/tv/orbit/classic/ChannelSchedule.kt +++ b/android/app/src/main/java/tv/orbit/classic/ChannelSchedule.kt @@ -31,7 +31,7 @@ internal data class ChannelProgramming(val number: Int, val name: String, val se } /** Expect the unexpected: standalone adventures by day in a mixed order, cult drama in order in prime time, and the strange stuff late. */ -private val ParadoxStandalones = listOf("Doctor Who (2005)", "Star Trek: The Next Generation", "The X-Files", "The Twilight Zone", "Stargate SG-1", "Sliders", "Warehouse 13", "Eureka") +private val ParadoxStandalones = listOf("Doctor Who (2005)", "Doctor Who (2024)", "Star Trek: The Next Generation", "The X-Files", "The Twilight Zone", "Stargate SG-1", "Sliders", "Warehouse 13", "Eureka") private val ParadoxPrimeTime = listOf("Buffy the Vampire Slayer", "Angel", "Supernatural", "Fringe") private val ParadoxLate = listOf("Twin Peaks", "The Outer Limits", "The Outer Limits (1995)", "Torchwood", "Farscape", "The X-Files") private val ParadoxShows get() = (ParadoxStandalones + ParadoxPrimeTime + ParadoxLate).distinct() 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 136f9bc1..e60c9c91 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt @@ -6,6 +6,9 @@ import java.net.URI import java.net.URLDecoder import java.net.URLEncoder +/** Copies of one show to compare, so a library with many duplicates can't cost a long read. */ +private const val MAX_SERIES_COPIES = 4 + internal class PlaybackSubtitle(val url: String, val mime: String, val language: String?, val label: String) internal class EmbyPlaybackPlan(val item: SampleItem, val url: String, val sourceId: String, val playSessionId: String, val subtitles: List, val durationMs: Long? = item.durationMs) @@ -207,15 +210,13 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v val match = bestSeriesMatch(search, if (programming.exactTitles) candidates.filter { seriesKey(it.title) == seriesKey(search) } else candidates) ?: continue // A second copy of a show in the library counts as the same show. if (pool.any { it.id == match.id || seriesKey(it.title) == seriesKey(match.title) }) continue - // If the best copy has nothing this box can play, another copy of the same show may. - val copies = listOf(match) + candidates.filter { it.id != match.id && seriesKey(it.title) == seriesKey(match.title) }.sortedBy { it.year ?: Int.MAX_VALUE } - for ((tried, copy) in copies.withIndex()) { - val whole = readWholeSeries(transport, userId, ::currentToken, copy, checkActive, onRequest = { requests++ }, canDecode = BoxDecoders::canDecode, englishAudio = programming.englishAudio) - if (whole.episodes.isEmpty()) continue - pool += whole - if (tried > 0) android.util.Log.i("OrbitSchedule", "channel=${programming.number} usedCopy=${tried + 1} of ${copies.size}") - break - } + // A library can hold several copies of one show, one with a single episode and another with the whole run. + // The copy with the most episodes this box can play is the one the channel uses. + val copies = (listOf(match) + candidates.filter { it.id != match.id && seriesKey(it.title) == seriesKey(match.title) }.sortedBy { it.year ?: Int.MAX_VALUE }).take(MAX_SERIES_COPIES) + val read = copies.map { copy -> readWholeSeries(transport, userId, ::currentToken, copy, checkActive, onRequest = { requests++ }, canDecode = BoxDecoders::canDecode, englishAudio = programming.englishAudio) } + val best = read.maxByOrNull { it.episodes.size }?.takeIf { it.episodes.isNotEmpty() } ?: continue + if (copies.size > 1) android.util.Log.i("OrbitSchedule", "channel=${programming.number} copies=${copies.size} usedCopy=${read.indexOf(best) + 1} episodes=${read.map { it.episodes.size }}") + pool += best } for (accepted in choices.accepted) { checkActive()