0.84.1: when the best copy of a show has nothing playable here, try its other copies
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m53s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m22s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-03 11:49:48 +00:00
co-authored by Claude Opus 5.5
parent bdc8ad8615
commit fae742971c
4 changed files with 13 additions and 6 deletions
@@ -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.84.0\"")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.84.1\"")
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
if (request.method == "POST") {
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
@@ -207,8 +207,15 @@ 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
val whole = readWholeSeries(transport, userId, ::currentToken, match, checkActive, onRequest = { requests++ }, canDecode = BoxDecoders::canDecode, englishAudio = programming.englishAudio)
if (whole.episodes.isNotEmpty()) pool += whole
// 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
}
}
for (accepted in choices.accepted) {
checkActive()
@@ -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.84.0")
next.setRequestProperty("User-Agent", "OrbitTV/0.84.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()) {