0.99.17: Vortex Afterburn premiere of Dragon Ball Super: Beerus (Stage D1)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m3s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m28s

Saturday 21:00 from 21 November, first airings only, two a night while two are waiting, each episode its own booking,
pinned to Emby 8016753; whole Dragon Ball film before it on premiere nights, never cut. Fresh box-data replay; every
channel's fingerprint identical to 0.99.16.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-04 16:07:15 +00:00
co-authored by Claude Opus 5.5
parent ef30493924
commit d5fa2edeab
15 changed files with 487 additions and 63 deletions
@@ -124,13 +124,34 @@ private val VortexLate = listOf("Attack on Titan", "Ghost in the Shell: Stand Al
"Tears to Tiara", "Zakuro", "Karas", "The Maxx", "Legend of the Galactic Heroes Gaiden", "Dragon Ball Z Abridged",
"Dragon Ball Z", "Gundam Wing", "Mobile Suit Gundam Wing", "Outlaw Star", "The Big O", "Trigun", "Megalobox", "Kingdom (2012)", "Fighting Spirit")
/** What Vortex asks the library for. Its other favourites came in as reviewed suggestions. */
internal val VortexShows get() = (VortexCartoons + VortexAnime + "Pokémon").distinct()
internal val VortexShows get() = (VortexCartoons + VortexAnime + "Pokémon" + BEERUS).distinct()
/**
* The Vortex Afterburn premiere of Dragon Ball Super: Beerus (Stage D1, approved by Paul on 4 November 2026): Saturdays at
* 21:00 from 21 November 2026, two new episodes a night while two or more are waiting, then one, never a repeat. Only the
* complete copy, Emby 8016753, is used: the other copy is withdrawn from Vortex.
*/
internal const val BEERUS = "Dragon Ball Super: Beerus"
internal val BeerusPremiereFrom: java.time.LocalDate = java.time.LocalDate.of(2026, 11, 21)
internal const val BEERUS_OTHER_COPY = "8055740"
/**
* Movie Night on premiere nights: one whole Dragon Ball film of about an hour or less before the premiere, from Vortex's own
* pool. Battle of Gods and Resurrection 'F' tell the Beerus story, so they're left out.
*/
internal val VortexPremiereFilms = listOf("Dragon Ball: Mystical Adventure", "Dragon Ball Z: Wrath of the Dragon", "Dragon Ball Z: Dead Zone", "Dragon Ball Z: Lord Slug",
"Dragon Ball Z: Cooler's Revenge", "Dragon Ball Z: Fusion Reborn", "Dragon Ball Z: Bojack Unbound", "Dragon Ball Z: The World's Strongest", "Dragon Ball Z: Bio-Broly",
"Dragon Ball: Curse of the Blood Rubies", "Dragon Ball: Sleeping Princess in Devil's Castle", "Dragon Ball GT: A Hero's Legacy", "Dragon Ball Z: Super Android 13!",
"Dragon Ball Z: Broly - Second Coming", "Dragon Ball Z: The Return of Cooler", "Dragon Ball Z: The History of Trunks", "Dragon Ball Z: Bardock - The Father of Goku")
/**
* Movie Night comes first, so on Friday and Saturday it takes 20:00 to 22:00 and Toonami's evening hour picks up after the film.
* Daytime suggestions not yet placed by hand go late, never into the daytime. Evening suggestions keep their evening.
*/
internal val VortexDayParts get() = listOf(
DayPart(20, 22, group = "movie", days = setOf(DayOfWeek.FRIDAY, DayOfWeek.SATURDAY), key = "vortex.movie"),
// The premiere comes first, then on its nights a shorter, Dragon Ball Movie Night that ends before it; other Saturdays are as before.
DayPart(21, 22, listOf(BEERUS), days = setOf(DayOfWeek.SATURDAY), onTime = true, key = "vortex.afterburn.premiere", from = BeerusPremiereFrom, premiere = true, premiereBuffer = 2, graceMs = 10 * 60_000L),
DayPart(20, 21, VortexPremiereFilms, days = setOf(DayOfWeek.SATURDAY), once = true, key = "vortex.movie", premiereNights = true),
DayPart(20, 22, group = "movie", days = setOf(DayOfWeek.FRIDAY), key = "vortex.movie"),
DayPart(20, 22, group = "movie", days = setOf(DayOfWeek.SATURDAY), key = "vortex.movie", premiereNights = false),
// Mornings are the staples. Reviewed modern anime joins in the afternoon, so it complements the channel rather than leading it.
DayPart(6, 12, VortexCartoons + VortexFavourites + listOf("Cardcaptor Sakura", "Cardcaptors", "Sailor Moon", "Dragon Ball", "Zoids: Chaotic Century", "Zoids")),
DayPart(12, 16, VortexCartoons + VortexFavourites + VortexFamilyAnime + listOf("Dragon Ball Z", "Mobile Suit Gundam Wing", "Tenchi Muyo! Ryo-Ohki", "Yu Yu Hakusho", "Outlaw Star", "The Big O")),
@@ -13,7 +13,21 @@ internal data class DayPart(val fromHour: Int, val toHour: Int, val titles: List
/** On a channel with weighted rotation: false keeps this block on equal turns, as Tots' Wind Down and Night (4 November 2026). */
val weighted: Boolean = true,
/** On a channel with weighted rotation: tier weights for this block only, over the channel's, as ToonZ's teatime trio. */
val weights: Map<String, Double> = emptyMap()) {
val weights: Map<String, Double> = emptyMap(),
/** An event that starts on this date: before it, the event gives way to the usual block. */
val from: java.time.LocalDate? = null,
/**
* A premiere (Stage D1, approved by Paul on 4 November 2026): a series event that only ever shows episodes not yet aired on
* Orbit, in order, [premiereDouble] a night while at least [premiereBuffer] are waiting, otherwise one, and nothing once
* they run out, so the slot goes back to the usual block rather than repeating one as new. Weighted channels only.
*/
val premiere: Boolean = false,
val premiereDouble: Int = 2,
val premiereBuffer: Int = 4,
/** Set to true for a block only on the channel's premiere nights, false for one only on its other nights. Null is every night. */
val premiereNights: Boolean? = null,
/** An appointment's own allowance for starting late, instead of [ON_TIME_GRACE_MS]. */
val graceMs: Long? = null) {
fun covers(hour: Int) = if (fromHour <= toHour) hour in fromHour until toHour else hour >= fromHour || hour < toHour
/** An event that runs past midnight belongs to the night it started, so its small hours count from the day before. */
fun covers(hour: Int, day: java.time.DayOfWeek) = covers(hour) && (days.isEmpty() || (if (fromHour > toHour && hour < toHour) day.minus(1) else day) in days)
@@ -168,7 +182,7 @@ internal val SmartChannels = listOf(
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(VORTEX_NUMBER, "Vortex", VortexShows, seriesCount = 40, finishTogether = true, exactTitles = true, englishAudio = false, tierWeights = VortexTiers, catalogueScaleHours = CATALOGUE_SCALE_HOURS,
dayParts = VortexDayParts,
dayParts = VortexDayParts, withdrawn = setOf(BEERUS_OTHER_COPY),
suggestionRules = listOf(
SuggestionRule("movie", "Movie Night", "Movie", listOf("Animation"), 1985..2025, 5f, setOf("NC-17", "X"), 30, setOf("Documentary"), 30, titleContains = "Dragon Ball"),
SuggestionRule("movie", "Movie Night", "Movie", listOf("Animation", "Action"), 1985..2015, 7f, setOf("NC-17", "X"), 30, setOf("Documentary", "Family"), 60),
@@ -551,19 +565,19 @@ internal fun nextAppointment(at: Long, zone: java.time.ZoneId, lookaheadHours: I
*/
internal fun <T> fitBeforeAppointment(appointment: Long, start: Long, chosen: T, candidates: List<T>, runInMs: Long = ON_TIME_RUN_IN_MS,
/** How many more programmes may follow before the appointment: 1 for series, 2 for films, which are long. */
followers: Int = 1, ends: (T) -> Long): T? {
val latest = appointment + ON_TIME_GRACE_MS
followers: Int = 1, graceMs: Long = ON_TIME_GRACE_MS, ends: (T) -> Long): T? {
val latest = appointment + graceMs
if (ends(chosen) <= appointment - runInMs) return null
val remaining = appointment - start
fun length(x: T) = ends(x) - start
/** Whether [first] can open a run of up to [followers] more different candidates that ends at the appointment or in its grace. */
fun opensRun(first: T): Boolean {
val total = length(first)
if (total in remaining..remaining + ON_TIME_GRACE_MS) return true
if (total in remaining..remaining + graceMs) return true
if (total > remaining) return false
val rest = candidates.filter { it != first }.map(::length)
if (followers >= 1 && rest.any { total + it in remaining..remaining + ON_TIME_GRACE_MS }) return true
if (followers >= 2) rest.forEachIndexed { i, a -> if (total + a < remaining) for (j in i + 1 until rest.size) if (total + a + rest[j] in remaining..remaining + ON_TIME_GRACE_MS) return true }
if (followers >= 1 && rest.any { total + it in remaining..remaining + graceMs }) return true
if (followers >= 2) rest.forEachIndexed { i, a -> if (total + a < remaining) for (j in i + 1 until rest.size) if (total + a + rest[j] in remaining..remaining + graceMs) return true }
return false
}
if (opensRun(chosen)) return null
@@ -645,10 +659,55 @@ internal fun extendWeighted(pool: List<PoolSeries>, cursor: ScheduleCursor, from
/** How long [show]'s next booking runs: the whole story when it opens one. */
fun lengthOf(show: PoolSeries): Long = following(show).let { episode -> storiesOf(show)?.takeIf { it.partOf(episode) == 0 }?.of(episode)?.durationMs ?: episode.durationMs }
fun hadItsTurn(available: List<PoolSeries>, at: Long) = available.any { film -> film.isFilm && shown[film.id]?.let { at - it < ONCE_A_NIGHT_MS } == true }
// A premiere event: its show, and the files already booked for it in the day before this stretch, so a night split by a top-up carries on.
val premierePart = dayParts.firstOrNull { it.premiere }
val premiereShows = premierePart?.let { p -> pool.filter { show -> p.titles.any { seriesKey(it) == seriesKey(show.title) } } }.orEmpty()
val premiereFiles = premiereShows.flatMapTo(HashSet()) { show -> show.episodes.map { it.id } }
/** The evening a time belongs to: the small hours count with the day before. */
fun nightOf(at: Long) = java.time.Instant.ofEpochMilli(at).atZone(zone).let { if (it.hour < 6) it.toLocalDate().minusDays(1) else it.toLocalDate() }
fun unaired(show: PoolSeries) = marks[show.id]?.let { mark -> show.episodes.count { it.mark > mark } } ?: show.episodes.size
/** Premiere episodes started on [night], booked in this stretch or just before it. */
fun premieresOn(night: java.time.LocalDate) = (aired.filterKeys { it in premiereFiles }.values + entries.filter { it.media.item.id in premiereFiles }.map { it.startMs })
.distinct().count { nightOf(it) == night }
fun premiereCap(show: PoolSeries, night: java.time.LocalDate): Int =
if (unaired(show) + premieresOn(night) >= premierePart!!.premiereBuffer) premierePart.premiereDouble else 1
/** Whether the premiere runs on the night of [at]: its day, on or after its start date, with a new episode to show or one already shown. */
fun premiereNight(at: Long): Boolean {
val p = premierePart ?: return false
val night = nightOf(at)
return (p.days.isEmpty() || night.dayOfWeek in p.days) && (p.from == null || !night.isBefore(p.from)) &&
premiereShows.any { unaired(it) > 0 || premieresOn(night) > 0 }
}
fun premiereStart(at: Long) = nightOf(at).atTime(premierePart!!.fromHour, 0).atZone(zone).toInstant().toEpochMilli()
/** Whether [part] may be used at [at] by the premiere rules, and with which of its shows. Null means it gives way. */
fun premiereFilter(part: DayPart, shows: List<PoolSeries>, at: Long): List<PoolSeries>? {
if (part.from != null && nightOf(at).isBefore(part.from)) return null
if (part.premiereNights != null && part.premiereNights != premiereNight(at)) return null
if (part.premiere) return shows.filter { unaired(it) > 0 && premieresOn(nightOf(at)) < premiereCap(it, nightOf(at)) }.ifEmpty { null }
// Before a premiere, only a film that ends in time for it: nothing is cut to make room.
if (part.premiereNights == true && premierePart != null) {
val latest = premiereStart(at) + (premierePart.graceMs ?: ON_TIME_GRACE_MS)
return shows.filter { !it.isFilm || at + it.episodes.first().durationMs <= latest }.ifEmpty { null }
}
return shows
}
fun partAt(at: Long): Triple<List<PoolSeries>, String, DayPart?> {
// A premiere night's second episode follows its first straight away, whatever the hour.
if (premierePart != null) premiereShows.firstOrNull { it.id == last && unaired(it) > 0 && premieresOn(nightOf(at)) in 1 until premiereCap(it, nightOf(at)) &&
entries.lastOrNull()?.media?.item?.id.let { id -> id == null || id in premiereFiles } }
?.let { return Triple(listOf(it), "event " + premierePart.group.ifEmpty { "${premierePart.fromHour}-${premierePart.toHour}" }, premierePart) }
val first = dayPartFor(pool, dayParts, at, zone)
val part = first.third ?: return first
return if (part.once && hadItsTurn(first.first, at)) dayPartFor(pool, dayParts - part, at, zone) else first
val spent = part.once && hadItsTurn(first.first, at)
var found = if (spent) dayPartFor(pool, dayParts - part, at, zone) else first
if (premierePart == null && dayParts.none { it.from != null || it.premiereNights != null }) return found
// Premiere rules: a part that gives way leaves the time to the next one that covers it.
var parts = if (spent) dayParts - part else dayParts
while (true) {
val candidate = found.third ?: return found
val allowed = premiereFilter(candidate, found.first, at) ?: run { parts = parts - candidate; found = dayPartFor(pool, parts, at, zone); null } ?: continue
return Triple(allowed, found.second, candidate)
}
}
// A show that has left the pool loses its tally, so if it comes back it joins level rather than owed a backlog.
val ids = pool.mapTo(HashSet()) { it.id }
@@ -687,7 +746,8 @@ internal fun extendWeighted(pool: List<PoolSeries>, cursor: ScheduleCursor, from
// Before an appointment, the eligible show that leaves it on time, then any clear one, in tally order.
val appointment = if (part?.onTime == true) null else nextAppointment(start, zone, partAt = ::partAt)
val fitted = if (continuing != null) null else appointment?.let { at -> fun ends(show: PoolSeries) = start + lengthOf(show)
fitBeforeAppointment(at, start, preferred, eligible.sortedWith(byTally), ends = ::ends) ?: fitBeforeAppointment(at, start, preferred, clear.sortedWith(byTally), ends = ::ends) }
val grace = partAt(at).third?.graceMs ?: ON_TIME_GRACE_MS
fitBeforeAppointment(at, start, preferred, eligible.sortedWith(byTally), graceMs = grace, ends = ::ends) ?: fitBeforeAppointment(at, start, preferred, clear.sortedWith(byTally), graceMs = grace, ends = ::ends) }
val series = continuing ?: fitted ?: preferred
val episode = following(series)
val story = storiesOf(series)?.let { it.of(episode)?.let { found -> found.parts.size to it.partOf(episode) + 1 } }
@@ -697,7 +757,8 @@ internal fun extendWeighted(pool: List<PoolSeries>, cursor: ScheduleCursor, from
series.id == last && unclashed.size < available.size -> "; again, as the others here air elsewhere then"
else -> ""
} + (if (fitted != null) "; chosen to finish before the appointment at ${java.time.Instant.ofEpochMilli(appointment!!).atZone(zone).toLocalTime()}" else "") +
(if (story != null) "; story: part 1 of ${story.first}, booked whole" else "")
(if (story != null) "; story: part 1 of ${story.first}, booked whole" else "") +
(if (part?.premiere == true && series in available) "; premiere: first airing on Orbit" else "")
val item = if (series.isFilm) SampleItem(series.title, "Movie", episode.durationMs / 60_000, "", episode.id, episode.durationMs) else scheduledItem(series.title, episode)
entries += ScheduleEntry(series.id, episode.mark, ScheduledMedia(item, episode.sourceId, episode.durationMs), start, why, if (series in available) part?.key.orEmpty() else "")
val weight = part?.takeIf { series in available }?.weights?.get(seriesKey(series.title)) ?: weightOf(series)
@@ -947,7 +1008,8 @@ internal class ScheduledChannel(val loop: SampleChannel, plan: ChannelPlan) : Sa
}
}
internal val PRESENTATION_KEY = Regex("[a-z0-9]{1,20}\\.[a-z0-9]{1,20}")
// Two or three parts, such as "riot.laughs" or "vortex.afterburn.premiere" (Stage D1).
internal val PRESENTATION_KEY = Regex("[a-z0-9]{1,20}(\\.[a-z0-9]{1,20}){1,2}")
/**
* A booked programme's presentation: the key saved with it when it was booked. A programme booked before keys were kept
@@ -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.99.16\"")
connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.99.17\"")
request.token?.let { connection.setRequestProperty("X-Emby-Token", it) }
if (request.method == "POST") {
val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8)
@@ -278,7 +278,9 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
if (pool.any { it.id == match.id || seriesKey(it.title) == seriesKey(match.title) }) continue
// 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)
// A copy taken off the channel by editorial decision is never read, so it can't stand in for the one chosen.
val copies = (listOf(match) + candidates.filter { it.id != match.id && seriesKey(it.title) == seriesKey(match.title) }.sortedBy { it.year ?: Int.MAX_VALUE })
.filter { it.id !in programming.withdrawn }.take(MAX_SERIES_COPIES)
val read = try { traced("read") { copies.map { copy -> readWholeSeries(transport, userId, ::currentToken, copy, checkActive, onRequest = { requests++ }, canDecode = BoxDecoders::canDecode, englishAudio = programming.englishAudio) } } }
catch (failure: EmbyCheckException) {
val kept = partial.carry(seriesKey(match.title), failure)
@@ -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.99.16")
next.setRequestProperty("User-Agent", "OrbitTV/0.99.17")
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()) {