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) <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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<PlaybackSubtitle>, 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()
|
||||
|
||||
Reference in New Issue
Block a user