Orbit brand packs for your channels: Orbit Mistletoe and Orbit Sakura

A channel named Mistletoe or Sakura (or given the Look on Review) wears the
pack: logo, guide card, bug, background and its Blender ident. Packs are
Orbit's own; a channel's file can only name one that exists.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-07 11:14:30 +00:00
co-authored by Claude Opus 5.5
parent 3d09528e5d
commit 3cad392cd5
18 changed files with 49 additions and 15 deletions
@@ -41,11 +41,11 @@ internal object ChannelBrands {
107 to ChannelBranding("evidence", "Orbit Evidence", R.drawable.evidence_epg, R.drawable.evidence_background, R.drawable.evidence_bug, ChannelCategory.Entertainment),
201 to ChannelBranding("orbit-terra", "Orbit Terra", R.drawable.orbit_terra_epg, R.drawable.orbit_terra_background, R.drawable.orbit_terra_bug, ChannelCategory.Documentaries),
106 to ChannelBranding("paradox", "Orbit Paradox", R.drawable.paradox_epg, R.drawable.paradox_background, R.drawable.paradox_bug, ChannelCategory.Entertainment))
fun forNumber(number: Int): ChannelBranding? = brands[number]
fun forNumber(number: Int): ChannelBranding? = brands[number] ?: CustomChannels.of(number)?.brand?.let { BrandPacks[it] }
/** Every channel's guide logo, to decode ahead. */
fun allLogos(): List<Int> = brands.values.map { it.logo }.distinct()
/** Saved channels keep their original names; what the viewer sees comes from the brand. */
fun displayName(channel: SampleChannel) = brands[channel.number]?.displayName ?: channel.name
fun displayName(channel: SampleChannel) = forNumber(channel.number)?.displayName ?: channel.name
}
internal fun availableSampleChannels(vararg channels: SampleChannel?): List<SampleChannel> =
@@ -56,3 +56,16 @@ internal fun channelAfter(numbers: List<Int>, current: Int, step: Int): Int {
val index = numbers.indexOf(current)
return if (index < 0 || numbers.isEmpty()) current else numbers[Math.floorMod(index + step, numbers.size)]
}
/**
* Orbit-made brand packs a channel of your own can wear (Paul, 7 November 2026: Orbit Mistletoe and Orbit Sakura): logo,
* guide bug, background and ident, so a channel made with Smart setup looks like one of Orbit's own.
*/
internal val BrandPacks: Map<String, ChannelBranding> = mapOf(
"orbit-mistletoe" to ChannelBranding("orbit-mistletoe", "Orbit Mistletoe", R.drawable.orbit_mistletoe_epg, R.drawable.orbit_mistletoe_background, R.drawable.orbit_mistletoe_bug, ChannelCategory.Movies),
"orbit-sakura" to ChannelBranding("orbit-sakura", "Orbit Sakura", R.drawable.orbit_sakura_epg, R.drawable.orbit_sakura_background, R.drawable.orbit_sakura_bug, ChannelCategory.Cartoons))
internal val BrandPackIdents: Map<String, Int> = mapOf("orbit-mistletoe" to R.raw.ident_mistletoe, "orbit-sakura" to R.raw.ident_sakura)
/** The pack whose name a channel's name matches ("Mistletoe" or "Orbit Mistletoe"), or null. */
internal fun brandPackFor(name: String): String? = BrandPacks.entries.firstOrNull { (_, b) ->
name.trim().equals(b.displayName, ignoreCase = true) || name.trim().equals(b.displayName.removePrefix("Orbit "), ignoreCase = true) }?.key
@@ -177,7 +177,7 @@ internal fun CreateChannelFlow(maker: ChannelMaker, editing: CustomChannel?, onD
// Editing on the TV keeps what the phone set: the season, and a shaped layout while the shows and style stay.
val kept = editing?.takeIf { it.style == style && it.shows.toSet() == chosen.map { c -> c.title }.toSet() }
val channel = CustomChannel(number, name.trim(), style, hours, description.trim(), chosen.map { it.title },
slots = kept?.slots.orEmpty(), core = kept?.core.orEmpty(), season = editing?.season)
slots = kept?.slots.orEmpty(), core = kept?.core.orEmpty(), season = editing?.season, brand = editing?.brand ?: brandPackFor(name))
onDone(runCatching { maker.create(channel, chosen) }.getOrElse { "That channel couldn't be made. Try again." })
}
}
@@ -42,11 +42,13 @@ internal data class CustomChannel(val number: Int, val name: String, val style:
/** Shaped only: each title's slot, and the core titles. */
val slots: Map<String, Slot> = emptyMap(), val core: Set<String> = emptySet(),
/** On air only through this part of the year, if you chose one (Paul, 7 November 2026: an optional choice, with dates). */
val season: SeasonWindow? = null) {
val season: SeasonWindow? = null,
/** An Orbit brand pack it wears ([BrandPacks]), or null for the plain Yours look. */
val brand: String? = null) {
init { require(number in YOURS_FIRST..YOURS_LAST && name.isNotBlank() && name.length <= 40) }
fun toJson(): JSONObject = JSONObject().put("number", number).put("name", name).put("style", style.name).put("description", description)
.put("hours", hours?.let { JSONObject().put("from", it.fromHour).put("to", it.toHour) } ?: JSONObject.NULL).put("shows", JSONArray(shows))
.put("slots", JSONObject(slots.mapValues { it.value.name })).put("core", JSONArray(core.toList())).put("season", season?.toJson() ?: JSONObject.NULL)
.put("slots", JSONObject(slots.mapValues { it.value.name })).put("core", JSONArray(core.toList())).put("season", season?.toJson() ?: JSONObject.NULL).put("brand", brand ?: JSONObject.NULL)
companion object {
fun fromJson(o: JSONObject) = CustomChannel(o.getInt("number"), o.getString("name").take(40),
runCatching { PlayStyle.valueOf(o.optString("style")) }.getOrDefault(PlayStyle.Standard),
@@ -54,7 +56,7 @@ internal data class CustomChannel(val number: Int, val name: String, val style:
o.optJSONArray("shows")?.let { a -> (0 until minOf(a.length(), 200)).map { a.getString(it).take(160) } }.orEmpty(),
o.optJSONObject("slots")?.let { m -> m.keys().asSequence().take(200).mapNotNull { k -> runCatching { k.take(160) to Slot.valueOf(m.getString(k)) }.getOrNull() }.toMap() }.orEmpty(),
o.optJSONArray("core")?.let { a -> (0 until minOf(a.length(), 20)).map { a.getString(it).take(160) }.toSet() }.orEmpty(),
SeasonWindow.of(o.optJSONObject("season")))
SeasonWindow.of(o.optJSONObject("season")), o.optString("brand").takeIf { it in BrandPacks })
}
}
@@ -62,9 +62,9 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
}
/** The sign-in headers for this kind of server. */
internal fun authHeaders(token: String?): Map<String, String> = when (kind) {
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.86\"") +
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.87\"") +
(token?.let { mapOf("X-Emby-Token" to it) } ?: emptyMap())
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.86\"" +
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.87\"" +
(token?.let { ", Token=\"$it\"" } ?: ""))
}
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
@@ -38,7 +38,7 @@ private val IdentVideos = mapOf(108 to R.raw.ident_108, 109 to R.raw.ident_109,
611 to R.raw.ident_611, 612 to R.raw.ident_612, 613 to R.raw.ident_613)
/** [atMs] is when the next programme starts, for a channel whose ident follows the time of day. */
internal fun identVideo(number: Int, atMs: Long = 0) = if (number == TOTS_NUMBER) totsVideo(atMs) else IdentVideos[number]
internal fun identVideo(number: Int, atMs: Long = 0) = if (number == TOTS_NUMBER) totsVideo(atMs) else IdentVideos[number] ?: CustomChannels.of(number)?.brand?.let { BrandPackIdents[it] }
internal fun identLength(number: Int, atMs: Long = 0) = when (number) {
TOTS_NUMBER -> totsMood(atMs).lengthMs
in IdentVideos -> IDENT_VIDEO_MS
@@ -324,6 +324,7 @@ internal object PhoneLink {
.put("networks", JSONArray(nets.map { (n, k) -> JSONObject().put("name", n).put("count", k) })).put("genres", JSONArray(genres))
.put("titles", JSONArray(titles.map(::suggestionJson))))
}
"GET /api/brands" -> json(out, 200, JSONObject().put("packs", JSONArray(BrandPacks.map { (k, b) -> JSONObject().put("key", k).put("name", b.displayName) })))
"GET /api/collections" -> {
val all = runBlocking { h.maker.collections() }
json(out, 200, JSONObject().put("collections", JSONArray(all.map { c -> JSONObject().put("name", c.name).put("count", c.members.size).put("total", c.total).put("complete", c.complete) })))
@@ -376,7 +377,9 @@ internal object PhoneLink {
if (shows.isEmpty()) return json(out, 400, JSONObject().put("error", "Add at least one show or film."))
// Shaped: the phone's layout, by item, kept by title as the planner reads it.
val titleOf = shows.associate { it.id to it.title }
val seasoned = channel.copy(season = SeasonWindow.of(o.optJSONObject("season")))
// An Orbit brand pack: the one chosen, else the one the name matches ("Sakura" wears Orbit Sakura).
val chosenBrand = if (o.has("brand")) o.optString("brand").takeIf { it in BrandPacks } else brandPackFor(channel.name)
val seasoned = channel.copy(season = SeasonWindow.of(o.optJSONObject("season")), brand = chosenBrand)
val laidOut = if (seasoned.style != PlayStyle.Shaped) seasoned else seasoned.copy(
slots = o.optJSONObject("slots")?.let { m -> m.keys().asSequence().mapNotNull { id -> titleOf[id]?.let { t -> runCatching { t to Slot.valueOf(m.getString(id)) }.getOrNull() } }.toMap() }.orEmpty(),
core = o.optJSONArray("core")?.let { a -> (0 until minOf(a.length(), 20)).mapNotNull { titleOf[a.getString(it)] }.toSet() }.orEmpty())
@@ -39,7 +39,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.108.86")
next.setRequestProperty("User-Agent", "OrbitTV/0.108.87")
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()) {