The Fall Guy plays its AVI copies; the general AVI restriction stays
Paul, 23 November 2026, after the playback test on the living room box (XviD and MP3: played, seeked and reopened cleanly, no stalls). A per-show exception (AviShows): the pool read and the player accept AVI for that show only. Knightmare waits for Paul to watch it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,18 @@ internal const val DirectVideoContainersBase = "mp4,mkv,mov,m4v,webm,ts,mpegts,3
|
||||
/** The containers Orbit plays directly; AVI only when its switch is on (PlayerSwitches, 9 November 2026). */
|
||||
internal val DirectVideoContainers: String get() = if (PlayerSwitches.avi) "$DirectVideoContainersBase,avi" else DirectVideoContainersBase
|
||||
|
||||
internal fun supportedDirectContainer(value: String): String? = value.trim().lowercase(java.util.Locale.ROOT)
|
||||
.takeIf { it in DirectVideoContainers.split(",") }
|
||||
internal fun supportedDirectContainer(value: String): String? = supportedDirectContainer(value, PlayerSwitches.avi)
|
||||
|
||||
/**
|
||||
* Shows whose AVI files play even with the AVI switch off (Paul, 23 November 2026): The Fall Guy, after its playback test on
|
||||
* the living room box (XviD and MP3: played, seeked and reopened cleanly, no stalls). The general AVI restriction stays;
|
||||
* Knightmare waits for Paul to watch it.
|
||||
*/
|
||||
internal val AviShows = setOf("The Fall Guy")
|
||||
internal fun aviAllowedFor(seriesTitle: String) = PlayerSwitches.avi || AviShows.any { seriesKey(it) == seriesKey(seriesTitle) }
|
||||
internal fun directContainers(allowAvi: Boolean) = if (allowAvi) "$DirectVideoContainersBase,avi" else DirectVideoContainersBase
|
||||
internal fun supportedDirectContainer(value: String, allowAvi: Boolean): String? = value.trim().lowercase(java.util.Locale.ROOT)
|
||||
.takeIf { it in directContainers(allowAvi).split(",") }
|
||||
|
||||
/** Only a short format label may reach diagnostics; never a raw URL/path from metadata. */
|
||||
internal fun safeContainerLabel(value: String): String = value.trim().lowercase(java.util.Locale.ROOT)
|
||||
|
||||
@@ -128,11 +128,13 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
|
||||
fun prepare(item: SampleItem, isPlayback: Boolean = true, preferredSourceId: String? = null): EmbyPlaybackPlan {
|
||||
if (preferredSourceId != null && !EmbyClient.validId(preferredSourceId)) throw EmbyCheckException("The channel source is no longer usable.")
|
||||
if (item.id.isBlank() || sample.items.none { it.id == item.id } && candidateEpisodes[item.id] != item && channelEpisodes[item.id] != item && darkCandidates.none { it.item == item } && darkLineup[item.id] != item) throw EmbyCheckException("Choose a title from the current sample.")
|
||||
// A show allowed AVI on its own (AviShows) plays its AVI copy even with the AVI switch off.
|
||||
val allowAvi = aviAllowedFor(item.title.substringBefore(" / "))
|
||||
val request = JSONObject().put("UserId", userId).put("IsPlayback", isPlayback)
|
||||
.put("EnableDirectPlay", true).put("EnableDirectStream", true).put("EnableTranscoding", false)
|
||||
.put("AutoOpenLiveStream", false)
|
||||
.put("DeviceProfile", JSONObject().put("Name", "Orbit TV playback test")
|
||||
.put("DirectPlayProfiles", JSONArray().put(JSONObject().put("Type", "Video").put("Container", DirectVideoContainers)))
|
||||
.put("DirectPlayProfiles", JSONArray().put(JSONObject().put("Type", "Video").put("Container", directContainers(allowAvi))))
|
||||
.put("TranscodingProfiles", JSONArray())
|
||||
.put("SubtitleProfiles", JSONArray().put(JSONObject().put("Format", "srt").put("Method", "External"))
|
||||
.put(JSONObject().put("Format", "vtt").put("Method", "External"))))
|
||||
@@ -147,13 +149,13 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
|
||||
(it.optBoolean("SupportsDirectStream") || it.optBoolean("SupportsDirectPlay")) && !it.optBoolean("RequiresOpening") && !it.optBoolean("RequiresClosing")
|
||||
}
|
||||
if (directSources.isEmpty()) throw EmbyCheckException("This title needs a playback method outside the current direct-stream test. Try another sample title.")
|
||||
val source = directSources.firstOrNull { supportedDirectContainer(it.optString("Container")) != null }
|
||||
val source = directSources.firstOrNull { supportedDirectContainer(it.optString("Container"), allowAvi) != null }
|
||||
?: throw EmbyCheckException("Unsupported direct container: ${directSources.map { safeContainerLabel(it.optString("Container")) }.distinct().take(3).joinToString(", ")}. Choose another series version for this sample.")
|
||||
val sourceId = source.optString("Id")
|
||||
if (!EmbyClient.validId(sourceId)) throw EmbyCheckException("The provider returned an unusable media source.")
|
||||
val playId = (if (info.isNull("PlaySessionId")) "" else info.optString("PlaySessionId")).ifBlank { java.util.UUID.randomUUID().toString() }
|
||||
if (!EmbyClient.validId(playId)) throw EmbyCheckException("The provider returned an unusable playback identity.")
|
||||
val container = requireNotNull(supportedDirectContainer(source.optString("Container")))
|
||||
val container = requireNotNull(supportedDirectContainer(source.optString("Container"), allowAvi))
|
||||
val url = "$apiBase/Videos/${item.id}/stream.$container?Static=true&MediaSourceId=${encode(sourceId)}&PlaySessionId=${encode(playId)}"
|
||||
val streams = source.optJSONArray("MediaStreams")
|
||||
val subtitles = (0 until minOf(streams?.length() ?: 0, 32)).mapNotNull { index ->
|
||||
|
||||
@@ -81,8 +81,9 @@ internal fun poolEpisode(item: org.json.JSONObject, canDecode: (String) -> Boole
|
||||
val number = item.optInt("IndexNumber", -1)
|
||||
if (item.optString("Type") != "Episode" || !EmbyClient.validId(id) || season < 1 || number < 1) return null
|
||||
val sources = item.optJSONArray("MediaSources") ?: return null
|
||||
val allowAvi = aviAllowedFor(item.optString("SeriesName"))
|
||||
val source = (0 until minOf(sources.length(), 20)).mapNotNull { sources.optJSONObject(it) }
|
||||
.firstOrNull { supportedDirectContainer(it.optString("Container")) != null && EmbyClient.validId(it.optString("Id")) && sourceVideoCodec(it)?.let(canDecode) != false && (!englishAudio || hasEnglishAudio(it)) } ?: return null
|
||||
.firstOrNull { supportedDirectContainer(it.optString("Container"), allowAvi) != null && EmbyClient.validId(it.optString("Id")) && sourceVideoCodec(it)?.let(canDecode) != false && (!englishAudio || hasEnglishAudio(it)) } ?: return null
|
||||
val ticks = source.optLong("RunTimeTicks", 0).takeIf { it > 0 } ?: item.optLong("RunTimeTicks", 0)
|
||||
val duration = (ticks / 10_000).takeIf { it in 1_000..SampleChannel.MAX_DURATION_MS } ?: return null
|
||||
return PoolEpisode(id, source.getString("Id"), EpisodeMark(season, number), EmbyClient.clean(item.optString("Name"), 160).ifBlank { "Untitled episode" }, duration)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
/** The Fall Guy's AVI exception (Paul, 23 November 2026): the show plays its AVI copies; the general AVI switch stays off. */
|
||||
class AviShowsTest {
|
||||
private fun episode(series: String) = JSONObject().put("Id", "e1").put("Type", "Episode").put("SeriesName", series).put("ParentIndexNumber", 3).put("IndexNumber", 16)
|
||||
.put("Name", "Rabbit's Feet").put("RunTimeTicks", 44 * 60 * 10_000_000L)
|
||||
.put("MediaSources", JSONArray().put(JSONObject().put("Id", "ms1").put("Container", "avi").put("RunTimeTicks", 44 * 60 * 10_000_000L)
|
||||
.put("MediaStreams", JSONArray().put(JSONObject().put("Type", "Video").put("Codec", "mpeg4")).put(JSONObject().put("Type", "Audio").put("Codec", "mp3")))))
|
||||
|
||||
@Test fun onlyTheFallGuyGetsItsAviCopies() {
|
||||
val before = PlayerSwitches.avi
|
||||
try {
|
||||
PlayerSwitches.avi = false
|
||||
assertNotNull(poolEpisode(episode("The Fall Guy"), { true }, true))
|
||||
assertNull(poolEpisode(episode("Knightmare"), { true }, true))
|
||||
assertEquals(null, supportedDirectContainer("avi"))
|
||||
assertEquals("avi", supportedDirectContainer("avi", aviAllowedFor("The Fall Guy")))
|
||||
assertEquals(DirectVideoContainersBase, directContainers(aviAllowedFor("Street Hawk")))
|
||||
} finally { PlayerSwitches.avi = before }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user