diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 2fb0705a..b5c2ab0d 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -9,8 +9,8 @@ android { applicationId = "tv.orbit.classic" minSdk = 26 targetSdk = 36 - versionCode = 246 - versionName = "0.108.86-create-v3" + versionCode = 247 + versionName = "0.108.87-mistletoe-sakura" } buildFeatures { compose = true } // The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so diff --git a/android/app/src/main/assets/phone/companion.html b/android/app/src/main/assets/phone/companion.html index 3be90507..4725a7bd 100644 --- a/android/app/src/main/assets/phone/companion.html +++ b/android/app/src/main/assets/phone/companion.html @@ -395,6 +395,7 @@ function reviewView() { ${d.number || state.channels?.next || ''} ${!d.name && c.suggestedName ? `
The Director suggests ${esc(c.suggestedName)}
` : ''}
${pillBtn(esc(style), 'data-kstyles="1"')}${pillBtn(esc(hours), 'data-kgo="when"')}${pillBtn(d.season ? seasonLabel(d.season) : 'All year', 'data-kgo="when"')}
+ ${(state.brands || []).length ? `
Look: ${[{key: '', name: 'Plain'}].concat(state.brands).map(b => ``).join('')}
` : ''} ${c.styleOpen ? `
${STYLES.map(([k, t, l]) => ``).join('')}
` : ''}`; // The week, in plain words. const total = sh?.hours; @@ -415,6 +416,8 @@ function reviewView() { `; } +// Orbit brand packs: chosen here, or matched by name ("Sakura" wears Orbit Sakura) until you choose. +const brandOf = d => d.brand !== undefined ? d.brand : ((state.brands || []).find(b => [b.name, b.name.replace(/^Orbit /, '')].some(n => n.toLowerCase() === (d.name || '').trim().toLowerCase()))?.key || ''); function doneView() { const c = state.create, k = c.done; return `
✓
@@ -474,7 +477,9 @@ function startCreate(draft) { } // Name the Director suggests: the collection's own name, or the description in a few words. const suggestName = text => text.replace(/\s+/g, ' ').trim().split(' ').slice(0, 3).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ').slice(0, 40); -function goTo(view) { const c = state.create; c.view = view; c.note = ''; render(); scrollTo(0, 0); +function goTo(view) { const c = state.create; c.view = view; c.note = ''; + if (view === 'review' && !state.brands) api('/api/brands').then(r => { state.brands = r.packs; if (state.create?.view === 'review') render(); }).catch(() => { state.brands = []; }); + render(); scrollTo(0, 0); if (view === 'shape' || (view === 'review' && !c.shape) || view === 'when') shapeShows(); if (view === 'review') checkClashes(); } async function runSearch() { const c = state.create; c.query = ($('#kq')?.value || '').trim(); if (c.query.length < 2 || c.busy) return; @@ -566,7 +571,8 @@ async function makeChannel(ending) { d.name = ($('#kname')?.value || d.name || '').trim(); if (!d.name) { toast('Give it a name first'); return; } c.busy = true; render(); try { const r = await api('/api/channels', {number: d.number, name: d.name, description: d.description, style: d.style, hours: d.hours, shows: d.shows, - slots: d.style === 'Shaped' ? d.slots : undefined, core: d.style === 'Shaped' ? d.core : undefined, season: d.season || null}); + slots: d.style === 'Shaped' ? d.slots : undefined, core: d.style === 'Shaped' ? d.core : undefined, season: d.season || null, + brand: d.brand !== undefined ? d.brand : undefined}); c.done = {number: r.number, name: d.name, message: r.message, edit: !!d.number}; c.busy = false; render(); load('more'); // Create & watch next: queued for after the programme on now, never interrupting it (Paul, 7 November 2026). if (ending === 'next') { await watchNew('next'); } @@ -705,6 +711,7 @@ document.addEventListener('click', e => { if (d.kseechosen) { chosenSheet(); return; } if (d.kunpick) { const dr = state.create.draft; dr.shows = dr.shows.filter(x => x.id !== d.kunpick); chosenSheet(); render(); return; } if (d.kmake) { makeChannel(d.kmake); return; } + if (d.kbrand !== undefined) { const c = state.create; c.draft.name = ($('#kname')?.value || c.draft.name || '').trim(); c.draft.brand = d.kbrand; render(); return; } if (d.create) { startCreate({name: '', description: '', style: 'Shaped', hours: null, shows: [], skipped: []}); return; } if (d.edit) { const ch = state.channels?.channels.find(x => x.number === +d.edit); if (!ch) return; api('/api/shows?number=' + ch.number).then(shows => { diff --git a/android/app/src/main/java/tv/orbit/classic/ChannelBranding.kt b/android/app/src/main/java/tv/orbit/classic/ChannelBranding.kt index f65bf657..c40f1a04 100644 --- a/android/app/src/main/java/tv/orbit/classic/ChannelBranding.kt +++ b/android/app/src/main/java/tv/orbit/classic/ChannelBranding.kt @@ -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 = 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 = @@ -56,3 +56,16 @@ internal fun channelAfter(numbers: List, 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 = 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 = 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 diff --git a/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt b/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt index f4314f26..31d4aecd 100644 --- a/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt +++ b/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt @@ -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." }) } } diff --git a/android/app/src/main/java/tv/orbit/classic/CustomChannels.kt b/android/app/src/main/java/tv/orbit/classic/CustomChannels.kt index 767c12ba..8c170c4d 100644 --- a/android/app/src/main/java/tv/orbit/classic/CustomChannels.kt +++ b/android/app/src/main/java/tv/orbit/classic/CustomChannels.kt @@ -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 = emptyMap(), val core: Set = 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 }) } } diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt index 396a8bcc..03623a43 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt @@ -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 = 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. */ diff --git a/android/app/src/main/java/tv/orbit/classic/Idents.kt b/android/app/src/main/java/tv/orbit/classic/Idents.kt index 062b2ab5..04bfd4e7 100644 --- a/android/app/src/main/java/tv/orbit/classic/Idents.kt +++ b/android/app/src/main/java/tv/orbit/classic/Idents.kt @@ -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 diff --git a/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt b/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt index f2e79da1..2b20de5c 100644 --- a/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt +++ b/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt @@ -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()) diff --git a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt index 1297da74..3b5491d0 100644 --- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt +++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt @@ -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()) { diff --git a/android/app/src/main/res/drawable-nodpi/orbit_mistletoe_background.webp b/android/app/src/main/res/drawable-nodpi/orbit_mistletoe_background.webp new file mode 100644 index 00000000..ad4ac58a Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/orbit_mistletoe_background.webp differ diff --git a/android/app/src/main/res/drawable-nodpi/orbit_mistletoe_bug.webp b/android/app/src/main/res/drawable-nodpi/orbit_mistletoe_bug.webp new file mode 100644 index 00000000..369d3596 Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/orbit_mistletoe_bug.webp differ diff --git a/android/app/src/main/res/drawable-nodpi/orbit_mistletoe_epg.webp b/android/app/src/main/res/drawable-nodpi/orbit_mistletoe_epg.webp new file mode 100644 index 00000000..0b7376be Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/orbit_mistletoe_epg.webp differ diff --git a/android/app/src/main/res/drawable-nodpi/orbit_sakura_background.webp b/android/app/src/main/res/drawable-nodpi/orbit_sakura_background.webp new file mode 100644 index 00000000..f9939e8e Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/orbit_sakura_background.webp differ diff --git a/android/app/src/main/res/drawable-nodpi/orbit_sakura_bug.webp b/android/app/src/main/res/drawable-nodpi/orbit_sakura_bug.webp new file mode 100644 index 00000000..0aaaafc2 Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/orbit_sakura_bug.webp differ diff --git a/android/app/src/main/res/drawable-nodpi/orbit_sakura_epg.webp b/android/app/src/main/res/drawable-nodpi/orbit_sakura_epg.webp new file mode 100644 index 00000000..3988892b Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/orbit_sakura_epg.webp differ diff --git a/android/app/src/main/res/raw/ident_mistletoe.mp4 b/android/app/src/main/res/raw/ident_mistletoe.mp4 new file mode 100644 index 00000000..4a49d132 Binary files /dev/null and b/android/app/src/main/res/raw/ident_mistletoe.mp4 differ diff --git a/android/app/src/main/res/raw/ident_sakura.mp4 b/android/app/src/main/res/raw/ident_sakura.mp4 new file mode 100644 index 00000000..ea43cc06 Binary files /dev/null and b/android/app/src/main/res/raw/ident_sakura.mp4 differ diff --git a/android/app/src/test/java/tv/orbit/classic/SmartSetupTest.kt b/android/app/src/test/java/tv/orbit/classic/SmartSetupTest.kt index bf1b90a3..11db7ae7 100644 --- a/android/app/src/test/java/tv/orbit/classic/SmartSetupTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/SmartSetupTest.kt @@ -85,4 +85,13 @@ class SmartSetupTest { val before = YourBriefs try { YourBriefs = listOf(brief); assertTrue(Briefs.any { it.number == 701 }); assertTrue(Briefs.any { it.number == 101 }) } finally { YourBriefs = before } } + + @Test fun yourChannelsCanWearAnOrbitBrandPack() { + assertEquals("orbit-sakura", brandPackFor("Sakura")); assertEquals("orbit-mistletoe", brandPackFor("orbit mistletoe")); assertNull(brandPackFor("The Unknown")) + val c = CustomChannel(702, "Sakura", PlayStyle.Shaped, brand = "orbit-sakura") + assertEquals("orbit-sakura", CustomChannel.fromJson(JSONObject(c.toJson().toString())).brand) + assertNull(CustomChannel.fromJson(JSONObject(c.copy(brand = null).toJson().toString())).brand) + assertNull(CustomChannel.fromJson(JSONObject(c.toJson().put("brand", "not-a-pack").toString())).brand) // only Orbit's own packs + CustomChannels.clear() + } }