Prefer English sound and leave out foreign-only episodes; record Paul's channel ideas (0.62.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,8 @@ android {
|
||||
applicationId = "tv.orbit.classic"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 62
|
||||
versionName = "0.61.0-unplayable-files"
|
||||
versionCode = 63
|
||||
versionName = "0.62.0-english-audio"
|
||||
}
|
||||
buildFeatures { compose = true }
|
||||
compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 }
|
||||
|
||||
@@ -23,6 +23,14 @@ internal fun sourceVideoCodec(source: org.json.JSONObject): String? {
|
||||
.firstOrNull { it.optString("Type") == "Video" }?.optString("Codec")?.takeIf { it.isNotBlank() }
|
||||
}
|
||||
|
||||
/** False only when a source's sound is all tagged as other languages. Untagged sound gets the benefit of the doubt. */
|
||||
internal fun hasEnglishAudio(source: org.json.JSONObject): Boolean {
|
||||
val streams = source.optJSONArray("MediaStreams") ?: return true
|
||||
val tags = (0 until minOf(streams.length(), 32)).mapNotNull { streams.optJSONObject(it) }.filter { it.optString("Type") == "Audio" }
|
||||
.map { it.optString("Language").trim().lowercase(java.util.Locale.ROOT) }
|
||||
return tags.isEmpty() || tags.any { it.isEmpty() || it == "und" || it == "en" || it == "eng" || it == "english" }
|
||||
}
|
||||
|
||||
/** The decoders this box actually has, read once. */
|
||||
internal object BoxDecoders {
|
||||
private val types by lazy {
|
||||
|
||||
@@ -17,7 +17,9 @@ internal data class ChannelProgramming(val number: Int, val name: String, val se
|
||||
/** Only the exact title counts, for channels whose short names could match something unrelated. */
|
||||
val exactTitles: Boolean = false,
|
||||
val dayParts: List<DayPart> = emptyList(),
|
||||
val suggestionRules: List<SuggestionRule> = emptyList()) {
|
||||
val suggestionRules: List<SuggestionRule> = emptyList(),
|
||||
/** Leave out episodes with no English sound. Off where subtitled shows belong, like Vortex's anime. */
|
||||
val englishAudio: Boolean = true) {
|
||||
/** Changes when the list does, so the episode cache is read again. What's already committed stays. */
|
||||
val signature get() = "$CHANNEL_POOL_VERSION#${searches.joinToString("|")}#$seriesCount"
|
||||
}
|
||||
@@ -44,7 +46,7 @@ internal val SmartChannels = listOf(
|
||||
SuggestionRule("day", "Daytime", "Movie", listOf("Science Fiction", "Action"), 1975..2005, 6.5f, setOf("NC-17", "X"), 40, NotCultCinema + "Adventure", 70, 7.9f),
|
||||
SuggestionRule("day", "Daytime", "Movie", listOf("Thriller", "Mystery"), 1975..2005, 6.5f, setOf("NC-17", "X"), 30, NotCultCinema + "Science Fiction", 70, 7.9f),
|
||||
SuggestionRule("late", "Late night", "Movie", listOf("Horror"), 1970..2010, 6f, emptySet(), 90, NotCultCinema, 70))),
|
||||
ChannelProgramming(103, "Vortex", VortexDaytime + VortexEvening, seriesCount = 40, finishTogether = true, exactTitles = true,
|
||||
ChannelProgramming(103, "Vortex", VortexDaytime + VortexEvening, seriesCount = 40, finishTogether = true, exactTitles = true, englishAudio = false,
|
||||
dayParts = listOf(DayPart(20, 22, group = "movie", days = setOf(java.time.DayOfWeek.FRIDAY, java.time.DayOfWeek.SATURDAY)),
|
||||
DayPart(6, 18, VortexDaytime, group = "day"), DayPart(18, 6, VortexEvening, group = "night")),
|
||||
suggestionRules = listOf(
|
||||
@@ -99,7 +101,7 @@ internal data class ChannelPlan(val entries: List<ScheduleEntry>, val tail: Sche
|
||||
}
|
||||
|
||||
/** Bump when the way pools are read changes, so each channel reads its once again. */
|
||||
private const val CHANNEL_POOL_VERSION = 3
|
||||
private const val CHANNEL_POOL_VERSION = 4
|
||||
|
||||
internal const val SCHEDULE_AHEAD_MS = 7 * 24 * 60 * 60_000L
|
||||
internal const val SCHEDULE_TOP_UP_MS = 6 * 24 * 60 * 60_000L
|
||||
|
||||
@@ -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.61.0\"")
|
||||
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.62.0\"")
|
||||
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
|
||||
if (request.method == "POST") {
|
||||
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
|
||||
|
||||
@@ -65,6 +65,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
.setSeekBackIncrementMs(10_000).setSeekForwardIncrementMs(10_000).build().apply {
|
||||
setMediaItem(channelMediaItem(plan))
|
||||
if (scheduled != null) seekTo(scheduled.programme.offsetAt(scheduled.nowMs()))
|
||||
trackSelectionParameters = trackSelectionParameters.buildUpon().setPreferredAudioLanguage("en").build()
|
||||
prepare(); playWhenReady = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ 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)
|
||||
val whole = readWholeSeries(transport, userId, ::currentToken, match, checkActive, onRequest = { requests++ }, canDecode = BoxDecoders::canDecode, englishAudio = programming.englishAudio)
|
||||
if (whole.episodes.isNotEmpty()) pool += whole
|
||||
}
|
||||
for (accepted in choices.accepted) {
|
||||
@@ -218,7 +218,7 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
|
||||
val duration = accepted.durationMs ?: continue
|
||||
pool += PoolSeries(accepted.id, accepted.title, listOf(PoolEpisode(accepted.id, source, EpisodeMark(1, 1), accepted.title, duration)), accepted.group)
|
||||
} else {
|
||||
val whole = readWholeSeries(transport, userId, ::currentToken, SeriesCandidate(accepted.id, accepted.title, accepted.year, ""), checkActive, onRequest = { requests++ }, canDecode = BoxDecoders::canDecode)
|
||||
val whole = readWholeSeries(transport, userId, ::currentToken, SeriesCandidate(accepted.id, accepted.title, accepted.year, ""), checkActive, onRequest = { requests++ }, canDecode = BoxDecoders::canDecode, englishAudio = programming.englishAudio)
|
||||
if (whole.episodes.isNotEmpty()) pool += whole.copy(group = accepted.group)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ internal const val WHOLE_SERIES_TIMEOUT_MS = 60_000
|
||||
|
||||
/** A whole series, read in bounded pages one at a time: regular numbered episodes with a playable source, once each, in order. */
|
||||
internal fun readWholeSeries(transport: EmbyTransport, userId: String, token: () -> String, series: SeriesCandidate,
|
||||
checkActive: () -> Unit = {}, onRequest: () -> Unit = {}, canDecode: (String) -> Boolean = { true }): PoolSeries {
|
||||
checkActive: () -> Unit = {}, onRequest: () -> Unit = {}, canDecode: (String) -> Boolean = { true }, englishAudio: Boolean = false): PoolSeries {
|
||||
require(EmbyClient.validId(userId) && EmbyClient.validId(series.id))
|
||||
val episodes = mutableListOf<PoolEpisode>()
|
||||
var start = 0
|
||||
@@ -68,21 +68,21 @@ internal fun readWholeSeries(transport: EmbyTransport, userId: String, token: ()
|
||||
EmbyClient.expectSuccess(reply.status, false)
|
||||
val body = EmbyClient.parse(reply.body)
|
||||
val rows = body.optJSONArray("Items") ?: throw EmbyCheckException("The provider did not return the episode list.")
|
||||
(0 until rows.length()).forEach { index -> rows.optJSONObject(index)?.let { poolEpisode(it, canDecode) }?.let { episodes += it } }
|
||||
(0 until rows.length()).forEach { index -> rows.optJSONObject(index)?.let { poolEpisode(it, canDecode, englishAudio) }?.let { episodes += it } }
|
||||
start += rows.length()
|
||||
if (rows.length() == 0 || start >= body.optInt("TotalRecordCount", 0)) break
|
||||
}
|
||||
return PoolSeries(series.id, series.title, episodes.sortedBy { it.mark }.distinctBy { it.mark })
|
||||
}
|
||||
|
||||
private fun poolEpisode(item: org.json.JSONObject, canDecode: (String) -> Boolean): PoolEpisode? {
|
||||
private fun poolEpisode(item: org.json.JSONObject, canDecode: (String) -> Boolean, englishAudio: Boolean): PoolEpisode? {
|
||||
val id = item.optString("Id")
|
||||
val season = item.optInt("ParentIndexNumber", -1)
|
||||
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 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 } ?: return null
|
||||
.firstOrNull { supportedDirectContainer(it.optString("Container")) != 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)
|
||||
|
||||
@@ -121,6 +121,7 @@ private fun GuideLivePlayer(session: EmbySampleSession, plan: EmbyPlaybackPlan,
|
||||
ExoPlayer.Builder(context).setMediaSourceFactory(DefaultMediaSourceFactory(factory)).build().apply {
|
||||
setMediaItem(channelMediaItem(plan))
|
||||
seekTo(programme.offsetAt(System.currentTimeMillis()))
|
||||
trackSelectionParameters = trackSelectionParameters.buildUpon().setPreferredAudioLanguage("en").build()
|
||||
prepare(); playWhenReady = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.61.0")
|
||||
next.setRequestProperty("User-Agent", "OrbitTV/0.62.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()) {
|
||||
|
||||
@@ -521,4 +521,21 @@ class ChannelScheduleTest {
|
||||
store.saveFailed(user, store.loadFailed(user) + "b")
|
||||
assertEquals(setOf("a", "b"), store.loadFailed(user))
|
||||
}
|
||||
|
||||
private fun withAudio(id: String, number: Int, vararg languages: String) = episode(id, 1, number).also { row ->
|
||||
val audio = JSONArray(); languages.forEach { audio.put(JSONObject().put("Type", "Audio").put("Language", it)) }
|
||||
row.getJSONArray("MediaSources").getJSONObject(0).put("MediaStreams", audio)
|
||||
}
|
||||
|
||||
@Test fun foreignOnlyEpisodesAreLeftOutWhereAChannelWantsEnglish() {
|
||||
val rows = JSONArray().put(withAudio("en", 1, "eng")).put(withAudio("fr", 2, "fre")).put(withAudio("both", 3, "spa", "eng")).put(withAudio("untagged", 4, "")).put(episode("none", 1, 5))
|
||||
val transport = EmbyTransport { EmbyReply(200, JSONObject().put("Items", rows).put("TotalRecordCount", rows.length()).toString()) }
|
||||
assertEquals(listOf("en", "both", "untagged", "none"), readWholeSeries(transport, user, { "t" }, series, englishAudio = true).episodes.map { it.id })
|
||||
assertEquals(5, readWholeSeries(transport, user, { "t" }, series, englishAudio = false).episodes.size)
|
||||
}
|
||||
|
||||
@Test fun vortexKeepsSubtitledShowsAndCartoonChannelsWantEnglish() {
|
||||
assertFalse(SmartChannels.first { it.number == 103 }.englishAudio)
|
||||
assertTrue(SmartChannels.first { it.number == 123 }.englishAudio)
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.9 MiB |
@@ -0,0 +1,22 @@
|
||||
# New channel ideas from Paul, 2 November 2026
|
||||
|
||||
Not yet built. Curated film pools, not genre matching. Films may appear on more than one channel, with a preferred home. Availability on Emby isn't verified.
|
||||
|
||||
## Detour: American comedy chaos ("Bad decisions. Great television.")
|
||||
Teen, college and road-trip comedy. Concept board: concepts/detour-concept.png.
|
||||
|
||||
American Pie (1999), American Pie 2 (2001), American Wedding (2003), American Reunion (2012), Road Trip (2000), EuroTrip (2004), Harold & Kumar Go to White Castle (2004), Harold & Kumar Escape from Guantanamo Bay (2008), A Very Harold & Kumar Christmas (2011), The Hangover (2009), The Hangover Part II (2011), The Hangover Part III (2013), Van Wilder (2002), Van Wilder: The Rise of Taj (2006), Old School (2003), Sex Drive (2008), Accepted (2006), Superbad (2007), Pineapple Express (2008), Dude, Where's My Car? (2000), Without a Paddle (2004), The Girl Next Door (2004), Not Another Teen Movie (2001), Project X (2012), 21 & Over (2013), Beerfest (2006), Grandma's Boy (2006), Waiting... (2005).
|
||||
|
||||
Programming ideas: Freshman Friday, Road Trip Saturday, Stoner Sundays, an occasional American Pie marathon. Kept apart from LOLZ, the Sandler, Carrey, Stiller and Ferrell channel.
|
||||
|
||||
## BritX: British cult cinema ("Proper films. Questionable characters.")
|
||||
Gangster cinema, dark humour, pub culture, football hooligan films, gritty dramas and cult horror. Concept board: concepts/britx-concept.png. Paul is unsure about the red X next to Orbit X.
|
||||
|
||||
Shaun of the Dead (2004), Hot Fuzz (2007), The World's End (2013), Lock, Stock and Two Smoking Barrels (1998), Snatch (2000), RocknRolla (2008), Layer Cake (2004), Trainspotting (1996), T2 Trainspotting (2017), Green Street (2005), The Football Factory (2004), Dog Soldiers (2002), Dead Man's Shoes (2004), 28 Days Later (2002), 28 Weeks Later (2007), This Is England (2006), The Gentlemen (2019), The Business (2005), The Firm (1989), Rise of the Footsoldier (2007), The 51st State (2001), Sexy Beast (2000), The Bank Job (2008), The Long Good Friday (1980), Human Traffic (1999), Twin Town (1997), Shallow Grave (1994), Four Lions (2010), Severance (2006), Attack the Block (2011), The Descent (2005), In Bruges (2008), Filth (2013), Calibre (2018), Sightseers (2012).
|
||||
|
||||
Programming ideas: Cornetto Friday, Gangster Saturday, Britain After Dark, Cult Classics, Scottish Cinema Nights (Trainspotting, Shallow Grave, Filth, Calibre, Sweet Sixteen).
|
||||
|
||||
## No logo ideas yet
|
||||
- Orbit Junior: Thomas the Tank Engine, Fireman Sam, Postman Pat, Brum, Rosie and Jim. Proper childhood telly.
|
||||
- Orbit Wild: Steve Irwin, Deadliest Catch, River Monsters, Bear Grylls. Nature's slightly more chaotic cousin to Terra.
|
||||
- Orbit Unsolved: ancient mysteries, UFO documentaries, unexplained phenomena. Paul is unsure whether Dark Files already covers it.
|
||||
Reference in New Issue
Block a user