Retry a failed decoder on channels, explain failures plainly, widen Dark Files (0.59.0)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m32s
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-02 10:02:50 +00:00
co-authored by Claude Opus 5.5
parent e630737b69
commit e14cfb00fd
7 changed files with 46 additions and 10 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 59
versionName = "0.58.0-comedy-dark-files"
versionCode = 60
versionName = "0.59.0-playback-retry"
}
buildFeatures { compose = true }
compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 }
@@ -5,9 +5,13 @@ internal data class ChannelPreset(val number: Int, val name: String, val searche
/** Started from its smart schedule alone, with no separate loop to build first. */
val smartOnly: Boolean = false)
internal val DarkFilesCrime = listOf("Forensic Files", "Cold Case Files", "The First 48", "Making a Murderer", "The Staircase", "The Jinx", "I Am a Killer", "Evil Lives Here", "Conversations with a Killer: The Ted Bundy Tapes", "Crime Scene: The Vanishing at the Cecil Hotel")
internal val DarkFilesMysteries = listOf("Unsolved Mysteries", "Wild Wild Country", "Dark Tourist", "Ancient Aliens")
internal val DarkFilesParanormal = listOf("Paranormal Witness", "Most Haunted", "Ghost Adventures", "Ghost Hunters", "Hellier")
internal val DarkFilesCrime = listOf("Forensic Files", "Cold Case Files", "The First 48", "Making a Murderer", "The Staircase", "The Jinx", "I Am a Killer", "Evil Lives Here", "Conversations with a Killer: The Ted Bundy Tapes", "Crime Scene: The Vanishing at the Cecil Hotel",
"Snapped", "American Justice", "City Confidential", "Homicide Hunter", "The Keepers", "Don't F**k with Cats: Hunting an Internet Killer", "The Confession Tapes", "Night Stalker: The Hunt for a Serial Killer",
"48 Hours", "Dateline NBC", "Tiger King", "Who Killed Sara?", "Time: The Kalief Browder Story")
internal val DarkFilesMysteries = listOf("Unsolved Mysteries", "Wild Wild Country", "Dark Tourist", "Ancient Aliens", "In Search Of...", "Ancient Mysteries", "Mysteries at the Museum", "Mysteries of the Abandoned", "The Curse of Oak Island",
"Hangar 1: The UFO Files", "Unidentified: Inside America's UFO Investigation", "Expedition Unknown", "Finding Bigfoot", "Arthur C. Clarke's Mysterious World")
internal val DarkFilesParanormal = listOf("Paranormal Witness", "Most Haunted", "Ghost Adventures", "Ghost Hunters", "Hellier", "A Haunting", "The Dead Files", "Paranormal State", "Ghost Brothers", "Kindred Spirits", "Haunted", "Ghost Stories",
"Celebrity Ghost Stories", "Ghost Asylum", "My Ghost Story")
internal val ChannelPresets = listOf(
ChannelPreset(140, "Terra", listOf("Blue Planet", "Planet Earth", "Frozen Planet", "Life", "Our Planet")),
@@ -57,7 +57,7 @@ internal val SmartChannels = listOf(
"Hostile Planet", "Africa", "Wild China", "South Pacific", "Great Barrier Reef", "The Hunt", "The Life of Mammals", "The Life of Birds", "Nature's Great Events", "Green Planet", "Prehistoric Planet"),
seriesCount = 20, finishTogether = true, exactTitles = true),
ChannelProgramming(152, "Paradox", ChannelPresets.first { it.number == 152 }.searches)) +
ChannelPresets.filter { it.smartOnly }.map { ChannelProgramming(it.number, it.name, it.searches, seriesCount = 40, finishTogether = true, exactTitles = true,
ChannelPresets.filter { it.smartOnly }.map { ChannelProgramming(it.number, it.name, it.searches, seriesCount = 60, finishTogether = true, exactTitles = true,
suggestionRules = SmartChannelRules[it.number].orEmpty(), dayParts = SmartChannelParts[it.number].orEmpty()) }
/** Dark Files, from the programming bible: crime by day, mysteries early evening, the paranormal late. */
@@ -70,7 +70,8 @@ private val SmartChannelRules: Map<Int, List<SuggestionRule>> get() = mapOf(
122 to listOf(SuggestionRule("all", "Classic cartoons", "Series", listOf("Animation", "Comedy"), 1940..1990, 6.5f, setOf("TV-MA"), 40)),
123 to listOf(SuggestionRule("all", "After-school cartoons", "Series", listOf("Animation", "Comedy"), 1990..2010, 7f, setOf("TV-MA"), 40, setOf("Anime"))),
124 to listOf(SuggestionRule("all", "Action cartoons", "Series", listOf("Animation", "Action"), 1980..2000, 6.5f, setOf("TV-MA"), 40, setOf("Anime"))),
142 to listOf(SuggestionRule("day", "Crime documentary", "Series", listOf("Documentary", "Crime"), 1990..2024, 7f, emptySet(), 30, setOf("Animation"))),
142 to listOf(SuggestionRule("day", "Crime documentary", "Series", listOf("Documentary", "Crime"), 1990..2024, 7f, emptySet(), 40, setOf("Animation")),
SuggestionRule("evening", "Mystery documentary", "Series", listOf("Documentary", "Mystery"), 1985..2024, 6.5f, emptySet(), 30, setOf("Animation"))),
113 to listOf(SuggestionRule("all", "Adult animation", "Series", listOf("Animation", "Comedy"), 1990..2024, 7.5f, emptySet(), 30, setOf("Anime", "Family", "Children"))),
141 to listOf(SuggestionRule("all", "Crime drama", "Series", listOf("Crime", "Drama"), 1985..2022, 7f, emptySet(), 40, setOf("Documentary", "Animation"))))
@@ -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.58.0\"")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.59.0\"")
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
if (request.method == "POST") {
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
@@ -35,6 +35,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
private const val MAX_PLAYER_RETRIES = 2
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
@Composable
internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPlan, onClose: () -> Unit, scheduled: ScheduledPlayback? = null,
@@ -48,6 +50,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
var lastInteraction by remember { mutableLongStateOf(SystemClock.elapsedRealtime()) }
fun showInfo() { infoVisible = true; lastInteraction = SystemClock.elapsedRealtime() }
var handedBack by remember { mutableStateOf(false) }
var playerRetries by remember { mutableIntStateOf(0) }
val openedAt = remember { SystemClock.elapsedRealtime() }
var numberEntry by remember { mutableStateOf<ChannelEntry?>(null) }
var numberProblem by remember { mutableStateOf<String?>(null) }
@@ -87,6 +90,13 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
if (onNumber(entry.number)) { numberEntry = null; numberProblem = null }
else numberProblem = "Channel ${entry.number} isn't available"
}
LaunchedEffect(playerRetries) {
if (playerRetries > 0 && scheduled != null) {
delay(800)
player.seekTo(scheduled.programme.offsetAt(scheduled.nowMs()))
player.prepare()
}
}
LaunchedEffect(numberEntry) { if (numberEntry != null) { delay(10_000); numberEntry = null; numberProblem = null } }
LaunchedEffect(subtitleNote) { if (subtitleNote != null) { delay(3_000); subtitleNote = null } }
val lifecycle = LocalLifecycleOwner.current.lifecycle
@@ -110,6 +120,18 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
playing = player.isPlaying
val listener = object : Player.Listener {
override fun onPlayerError(error: PlaybackException) {
android.util.Log.w("OrbitSchedule", "channel=${scheduled?.channel?.number} playerError=${error.errorCodeName} retry=$playerRetries")
// A decoder can be taken away during a quick channel change, so a channel tries again before giving up.
if (scheduled != null && playerRetries < MAX_PLAYER_RETRIES) {
ready = false
playerRetries++
return
}
if (scheduled != null) {
failure = "This programme won't play on this box. Orbit moves on at ${clock(scheduled.programme.endMs)}."
ready = false
return
}
val safeReason = generateSequence(error.cause) { it.cause }.filterIsInstance<MediaDeliveryException>().firstOrNull()?.message
failure = safeReason ?: "Playback could not continue (${error.errorCodeName}). Try another sample title, or return and report this code."
ready = false
@@ -253,7 +275,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
if (failure != null) Column(Modifier.align(Alignment.Center).widthIn(max = 620.dp).background(Navy).padding(24.dp)) {
Text(failure.orEmpty(), color = Color.White, fontSize = 20.sp)
Spacer(Modifier.height(16.dp))
OrbitButton("Return to sample", onClick = onClose)
OrbitButton(if (scheduled != null) "Back to TV guide" else "Return to sample", onClick = onClose)
}
}
}
@@ -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.58.0")
next.setRequestProperty("User-Agent", "OrbitTV/0.59.0")
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()) {
@@ -128,4 +128,13 @@ class ChannelPresetsTest {
assertEquals(listOf("Unsolved Mysteries"), dayPartPool(pool, parts, at(19), london).map { it.title })
assertEquals(listOf("Most Haunted"), dayPartPool(pool, parts, at(23), london).map { it.title })
}
@Test fun darkFilesCoversEveryBlockWithEnoughShows() {
assertTrue(DarkFilesCrime.size >= 20)
assertTrue(DarkFilesMysteries.size >= 10)
assertTrue(DarkFilesParanormal.size >= 15)
val all = ChannelPresets.first { it.number == 142 }.searches
assertEquals(all.size, all.distinct().size)
assertTrue(SmartChannels.first { it.number == 142 }.seriesCount >= all.size)
}
}