Build 77 (test): ATLAS's original-language sound and full English subtitles, dormant until ATLAS exists
- AtlasPlayback: per-title recorded original language, used only when the file has that sound track; English subtitles that are never forced (plain before SDH); channel 113 only, so every other channel plays as before - The viewer's choices on ATLAS last for that programme and aren't saved for other channels - The guide picture plays ATLAS's original sound too - Hand-run playback test (household): --es orbit_play_test_atlas "<title>" and --el orbit_play_test_offset <ms> apply ATLAS's rule and log the tracks chosen and the subtitles drawn (OrbitPlayTest, OrbitAtlas) - AtlasWeekPreviewTest: plans ATLAS's proposed first week from an audit pool (ATLAS_WEEK); a preview only - No ATLAS channel, preset or booking yet Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ plugins {
|
||||
id("org.jetbrains.kotlin.plugin.compose")
|
||||
}
|
||||
/** The release's build number: versionCode is this x 10 plus the edition's channel. */
|
||||
val ORBIT_BUILD = 76
|
||||
val ORBIT_BUILD = 77
|
||||
android {
|
||||
namespace = "tv.orbit.classic"
|
||||
compileSdk = 36
|
||||
|
||||
@@ -51,7 +51,10 @@ internal object Edition {
|
||||
/** The hand-run playback test opens over Orbit, which stops in the background as it would for any other app, and comes back when it ends. */
|
||||
fun openPlaybackTest(activity: Activity, intent: Intent?) {
|
||||
intent?.getStringExtra("orbit_play_test")?.takeIf(EmbyClient::validId)?.let { item ->
|
||||
activity.startActivity(Intent(activity, PlaybackTestActivity::class.java).putExtra(PlaybackTestActivity.ITEM, item))
|
||||
activity.startActivity(Intent(activity, PlaybackTestActivity::class.java).putExtra(PlaybackTestActivity.ITEM, item)
|
||||
// ATLAS's playback test (24 November 2026): the programme's title, for its original-language rule, and where to start.
|
||||
.putExtra(PlaybackTestActivity.ATLAS_TITLE, intent.getStringExtra("orbit_play_test_atlas"))
|
||||
.putExtra(PlaybackTestActivity.OFFSET, intent.getLongExtra("orbit_play_test_offset", 0L)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ import kotlinx.coroutines.withContext
|
||||
class PlaybackTestActivity : ComponentActivity() {
|
||||
companion object {
|
||||
const val ITEM = "item"
|
||||
const val ATLAS_TITLE = "atlas_title"
|
||||
const val OFFSET = "offset"
|
||||
const val TEST_MS = 3 * 60_000L
|
||||
}
|
||||
|
||||
@@ -43,7 +45,11 @@ class PlaybackTestActivity : ComponentActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
val item = intent?.getStringExtra(ITEM)?.takeIf(EmbyClient::validId) ?: run { finish(); return }
|
||||
setContent { MaterialTheme { PlaybackTest(item) { finish() } } }
|
||||
// ATLAS (24 November 2026): the programme's title in Orbit's form ("Squid Game / S1 E1"), so its original-language rule
|
||||
// applies as on channel 113; only letters, digits and plain punctuation, at most 80 characters.
|
||||
val atlas = intent?.getStringExtra(ATLAS_TITLE)?.takeIf { it.length <= 80 && it.all { c -> c.isLetterOrDigit() || c in " /:?!'.,&-" } }
|
||||
val offset = (intent?.getLongExtra(OFFSET, 0L) ?: 0L).coerceIn(0L, 4 * 60 * 60_000L)
|
||||
setContent { MaterialTheme { PlaybackTest(item, atlas, offset) { finish() } } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +61,7 @@ internal class PlaybackTestRecord {
|
||||
var audio = "none"
|
||||
var subtitles = emptyList<String>()
|
||||
var subtitleSelected = "none"
|
||||
var cueSamples = mutableListOf<String>()
|
||||
var cueUpdates = 0
|
||||
var firstCueMs: Long? = null
|
||||
var errors = 0
|
||||
@@ -68,7 +75,7 @@ internal fun playTestLabel(value: String?) = value?.trim()?.takeIf(SafeLabel::ma
|
||||
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
@Composable
|
||||
private fun PlaybackTest(itemId: String, done: () -> Unit) {
|
||||
private fun PlaybackTest(itemId: String, atlas: String?, offsetMs: Long, done: () -> Unit) {
|
||||
val context = LocalContext.current
|
||||
var session by remember { mutableStateOf<EmbySampleSession?>(null) }
|
||||
var plan by remember { mutableStateOf<EmbyPlaybackPlan?>(null) }
|
||||
@@ -92,7 +99,7 @@ private fun PlaybackTest(itemId: String, done: () -> Unit) {
|
||||
EmbyServer.origin = saved.origin
|
||||
val active = EmbyClient(HttpsEmbyTransport(saved.identity.deviceId, saved.origin)).resume(saved)
|
||||
session = active
|
||||
val item = SampleItem("Playback test", "Episode", null, "", itemId)
|
||||
val item = SampleItem(atlas ?: "Playback test", "Episode", null, "", itemId)
|
||||
active.rememberScheduledItems(listOf(item))
|
||||
plan = active.prepare(item)
|
||||
}
|
||||
@@ -112,7 +119,9 @@ private fun PlaybackTest(itemId: String, done: () -> Unit) {
|
||||
val active = session
|
||||
if (ready != null && active != null) {
|
||||
EmbyPlaybackDialog(active, ready, onClose = { finish("back") }, subtitlePreference = subtitles, announce = false, reportPlayback = false,
|
||||
policyChannel = if (atlas != null) ATLAS_NUMBER else null,
|
||||
onPlayer = { player ->
|
||||
if (offsetMs > 0) player.seekTo(offsetMs)
|
||||
player.addListener(object : Player.Listener {
|
||||
override fun onPlaybackStateChanged(state: Int) {
|
||||
if (state == Player.STATE_READY && !record.ready) { record.ready = true; Log.i("OrbitPlayTest", "playtest readyMs=${android.os.SystemClock.elapsedRealtime() - startedAt}") }
|
||||
@@ -136,6 +145,13 @@ private fun PlaybackTest(itemId: String, done: () -> Unit) {
|
||||
if (cueGroup.cues.isEmpty()) return
|
||||
record.cueUpdates++
|
||||
if (record.firstCueMs == null) { record.firstCueMs = player.currentPosition; Log.i("OrbitPlayTest", "playtest firstCuePositionMs=${record.firstCueMs}") }
|
||||
// ATLAS's test: what the subtitles actually drew (text cues, or an image for picture-based ones).
|
||||
if (atlas != null && record.cueSamples.size < 6) {
|
||||
val cue = cueGroup.cues.first()
|
||||
val sample = cue.text?.toString()?.replace('\n', ' ')?.take(60) ?: if (cue.bitmap != null) "[image ${cue.bitmap!!.width}x${cue.bitmap!!.height}]" else "[empty]"
|
||||
record.cueSamples += sample
|
||||
Log.i("OrbitPlayTest", "playtest cue at=${player.currentPosition} drew=$sample")
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
/**
|
||||
* ATLAS's sound and subtitles (Paul, 24 November 2026). International programmes play in their original language with full
|
||||
* English subtitles, never in a dub, and never with forced-only subtitles. Every other channel keeps Orbit's usual rule
|
||||
* (English sound where there is some, forced subtitles only unless the viewer asks), and nothing chosen on ATLAS is saved
|
||||
* for them.
|
||||
*
|
||||
* The files can't say which track is the original: many make a German or Portuguese dub their default (Squid Game, Cable
|
||||
* Girls, The 8 Show), and none marks the original. So each title's original language is written down here, from the
|
||||
* production itself, and is used only when the file really has a sound track in that language: a title whose original
|
||||
* sound isn't in the file isn't played this way at all, and doesn't belong on ATLAS. Multilingual productions whose own
|
||||
* mix is the English-labelled track (Shōgun, 1899, Giri/Haji) are written down as English, with English subtitles on, so
|
||||
* their other languages are understood.
|
||||
*
|
||||
* The viewer's own choice during a programme wins for that programme. It isn't saved, so the next programme, and any other
|
||||
* channel, decides afresh.
|
||||
*/
|
||||
internal const val ATLAS_NUMBER = 113
|
||||
|
||||
/** A sound or subtitle track as the player reports it, kept apart from Media3 so the rule can be tested. */
|
||||
internal data class AtlasTrack(val language: String?, val label: String? = null, val forced: Boolean = false)
|
||||
|
||||
/** What ATLAS plays for one programme: its original sound, and whether English subtitles go on. */
|
||||
internal data class AtlasTracks(val original: String, val subtitles: Boolean)
|
||||
|
||||
internal object AtlasPlayback {
|
||||
/**
|
||||
* Original languages, by series or film title as Orbit names it. The controlled TV test set first (24 November 2026):
|
||||
* Korean, Japanese, Spanish and Hindi, image-based subtitles, and multilingual productions.
|
||||
*/
|
||||
val originals: Map<String, String> = mapOf(
|
||||
"Squid Game" to "ko", "The 8 Show" to "ko", "Crash Landing on You" to "ko", "Extraordinary Attorney Woo" to "ko",
|
||||
"Alice in Borderland" to "ja", "Gannibal" to "ja", "Midnight Diner" to "ja",
|
||||
"Cable Girls" to "es", "Money Heist" to "es", "Who Killed Sara?" to "es", "Elite" to "es",
|
||||
"Sacred Games" to "hi", "Delhi Crime" to "hi", "Panchayat" to "hi",
|
||||
"Story of Yanxi Palace" to "zh", "The Killing" to "da",
|
||||
// In the test as a control: its later episodes have no English subtitles, so they must be refused.
|
||||
"Signal" to "ko",
|
||||
// Multilingual productions: their own mix is the English-labelled track; English subtitles cover the rest.
|
||||
"Shōgun" to "en+", "1899" to "en+", "Giri/Haji" to "en+")
|
||||
|
||||
/** The series or film a programme belongs to, from its title ("Squid Game / S1 E2 / Hell" → "Squid Game"). */
|
||||
fun titleOf(programme: String): String = programme.substringBefore(" / ").trim()
|
||||
|
||||
/** ATLAS's rule for this programme, or null: another channel, or a title with no recorded original language. */
|
||||
fun forProgramme(channel: Int?, programme: String): AtlasTracks? {
|
||||
if (channel != ATLAS_NUMBER) return null
|
||||
val original = originals[titleOf(programme)] ?: return null
|
||||
return if (original == "en+") AtlasTracks("en", subtitles = true) else AtlasTracks(original, subtitles = original != "en")
|
||||
}
|
||||
|
||||
/** The sound track in the original language, or null when the file has none (then the title doesn't play this way). */
|
||||
fun audioIndex(rule: AtlasTracks, audio: List<AtlasTrack>): Int? =
|
||||
audio.indexOfFirst { language(it.language) == rule.original }.takeIf { it >= 0 }
|
||||
|
||||
/**
|
||||
* The English subtitle track to show: never a forced one (by flag or by its label), and a plain one before one for the
|
||||
* deaf and hard of hearing (SDH, CC), which is still a full track and is taken when it's the only one.
|
||||
*/
|
||||
fun subtitleIndex(rule: AtlasTracks, subtitles: List<AtlasTrack>): Int? {
|
||||
if (!rule.subtitles) return null
|
||||
val full = subtitles.withIndex().filter { (_, t) -> language(t.language) == "en" && !t.forced && !mentions(t.label, "forced") }
|
||||
return (full.firstOrNull { (_, t) -> !mentions(t.label, "sdh") && !mentions(t.label, "cc") } ?: full.firstOrNull())?.index
|
||||
}
|
||||
|
||||
/** Whether a programme can be understood under the rule: its original sound, and full English subtitles when needed. */
|
||||
fun playable(rule: AtlasTracks, audio: List<AtlasTrack>, subtitles: List<AtlasTrack>): Boolean =
|
||||
audioIndex(rule, audio) != null && (!rule.subtitles || subtitleIndex(rule, subtitles) != null)
|
||||
|
||||
private fun mentions(label: String?, word: String) = label?.lowercase(java.util.Locale.ROOT)?.contains(word) == true
|
||||
|
||||
/** A language code as two letters, whichever form the file or Media3 gives (kor, ko, ko-KR, chi, zho, cmn, yue). */
|
||||
fun language(code: String?): String? {
|
||||
val c = code?.trim()?.lowercase(java.util.Locale.ROOT)?.substringBefore('-')?.substringBefore('_')?.takeIf { it.isNotEmpty() } ?: return null
|
||||
return Aliases[c] ?: c.takeIf { it.length == 2 }
|
||||
}
|
||||
|
||||
private val Aliases = mapOf(
|
||||
"kor" to "ko", "kr" to "ko", "jpn" to "ja", "jp" to "ja", "spa" to "es", "hin" to "hi", "chi" to "zh", "zho" to "zh",
|
||||
"cmn" to "zh", "yue" to "zh", "mdr" to "zh", "eng" to "en", "fre" to "fr", "fra" to "fr", "ger" to "de", "deu" to "de",
|
||||
"por" to "pt", "ita" to "it", "dan" to "da", "nor" to "no", "nob" to "no", "nb" to "no", "nno" to "no", "swe" to "sv",
|
||||
"heb" to "he", "iw" to "he", "tur" to "tr", "rus" to "ru", "pol" to "pl", "tha" to "th", "ind" to "id", "in" to "id",
|
||||
"per" to "fa", "fas" to "fa", "ara" to "ar", "ice" to "is", "isl" to "is", "dut" to "nl", "nld" to "nl", "tel" to "te",
|
||||
"tam" to "ta", "mal" to "ml", "kan" to "kn", "ben" to "bn", "mar" to "mr", "vie" to "vi", "cze" to "cs", "ces" to "cs")
|
||||
}
|
||||
@@ -82,6 +82,8 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
reportPlayback: Boolean = true,
|
||||
/** The playback test's own listener on the player, for its diagnostics. */
|
||||
onPlayer: ((ExoPlayer) -> Unit)? = null,
|
||||
/** The hand-run playback test only: the channel whose sound and subtitle rule applies when there's no schedule (ATLAS). */
|
||||
policyChannel: Int? = null,
|
||||
/** Catch Up: moves the channel's replay clock by this much (a skip, or time spent paused). */
|
||||
onShift: (Long) -> Unit = {},
|
||||
/** Catch Up: back to the channel live. */
|
||||
@@ -123,6 +125,9 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
val currentScheduled by rememberUpdatedState(scheduled)
|
||||
val shift by rememberUpdatedState(onShift)
|
||||
val live by rememberUpdatedState(onLive)
|
||||
// ATLAS's own rule for sound and subtitles (AtlasPlayback): this programme only, nothing saved for other channels.
|
||||
val atlas = remember(plan) { AtlasPlayback.forProgramme(scheduled?.channel?.number ?: policyChannel, plan.item.title) }
|
||||
var atlasApplied by remember(plan) { mutableStateOf(false) }
|
||||
val player = remember(session, plan) {
|
||||
if (runningPlayer != null) return@remember runningPlayer
|
||||
val factory = DataSource.Factory { SecureMediaDataSource(session) }
|
||||
@@ -132,7 +137,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
if (scheduled != null) seekTo(scheduled.programme.offsetAt(scheduled.nowMs()))
|
||||
// Until Orbit has chosen (below), only a track the programme marks as forced may show: never one the file merely
|
||||
// marks as default, which is how subtitles appeared with the setting off (0.129).
|
||||
trackSelectionParameters = forcedSubtitlesOnly(trackSelectionParameters.buildUpon().setPreferredAudioLanguage(audioPreference?.value ?: "en")).build()
|
||||
trackSelectionParameters = forcedSubtitlesOnly(trackSelectionParameters.buildUpon().setPreferredAudioLanguage(atlas?.original ?: audioPreference?.value ?: "en")).build()
|
||||
OrbitTiming.tune(scheduled?.channel?.number)
|
||||
if (OrbitTiming.on) addAnalyticsListener(object : androidx.media3.exoplayer.analytics.AnalyticsListener {
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
@@ -159,15 +164,33 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
val latestSubtitles by rememberUpdatedState(subtitlePreference)
|
||||
// The setting changed while this programme plays (on the TV or from the phone): it applies straight away (0.129).
|
||||
LaunchedEffect(subtitlePreference) {
|
||||
if (atlas != null) return@LaunchedEffect
|
||||
val available = textTracks()
|
||||
if (available.isNotEmpty()) chooseSubtitle(subtitleChoice(subtitlePreference?.value, audioLanguages(), available.map { it.getTrackFormat(0).language.orEmpty() }), available)
|
||||
}
|
||||
fun chooseAudio(group: Tracks.Group) {
|
||||
player.trackSelectionParameters = player.trackSelectionParameters.buildUpon().clearOverridesOfType(C.TRACK_TYPE_AUDIO)
|
||||
.addOverride(TrackSelectionOverride(group.mediaTrackGroup, 0)).build()
|
||||
audioPreference?.value = group.getTrackFormat(0).language
|
||||
// On ATLAS the viewer's choice is for this programme only: it isn't carried to other channels.
|
||||
if (atlas == null) audioPreference?.value = group.getTrackFormat(0).language
|
||||
audioChosen = true
|
||||
}
|
||||
fun trackInfo(group: Tracks.Group) = group.getTrackFormat(0).let { AtlasTrack(it.language, it.label, it.selectionFlags and C.SELECTION_FLAG_FORCED != 0) }
|
||||
/** ATLAS: the original sound and full English subtitles, once per programme, before the viewer chooses anything. */
|
||||
fun applyAtlas(rule: AtlasTracks) {
|
||||
atlasApplied = true
|
||||
val audio = player.currentTracks.groups.filter { it.type == C.TRACK_TYPE_AUDIO && it.isSupported }
|
||||
val text = textTracks()
|
||||
val a = AtlasPlayback.audioIndex(rule, audio.map(::trackInfo))
|
||||
val t = AtlasPlayback.subtitleIndex(rule, text.map(::trackInfo))
|
||||
if (a != null) player.trackSelectionParameters = player.trackSelectionParameters.buildUpon().clearOverridesOfType(C.TRACK_TYPE_AUDIO)
|
||||
.addOverride(TrackSelectionOverride(audio[a].mediaTrackGroup, 0)).build()
|
||||
chooseSubtitle(t, text)
|
||||
val ok = a != null && (!rule.subtitles || t != null)
|
||||
// For the playback test (adb logcat -s OrbitAtlas) and the notes: languages and labels only, no titles.
|
||||
android.util.Log.i("OrbitAtlas", "item=${plan.item.id} original=${rule.original} audio=${a?.let { audio[it].getTrackFormat(0).language }} subtitle=${t?.let { text[it].getTrackFormat(0).let { f -> "${f.language}:${f.label}:${f.sampleMimeType}" } }} ok=$ok")
|
||||
if (!ok) PlaybackNotes.add(notes, "channel=${scheduled?.channel?.number} item=${plan.item.id} atlas=${if (a == null) "no original sound" else "no full English subtitles"}")
|
||||
}
|
||||
fun trackRows(): List<TrackRow> {
|
||||
val (subSize, subBox) = subtitleStyle
|
||||
val styleRows = if (textTracks().isEmpty()) emptyList() else
|
||||
@@ -175,11 +198,11 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
listOf("Shadow" to false, "Box" to true).map { (label, box) -> TrackRow("Subtitle background", label, subBox == box) { subtitleStyle = subSize to box; SubtitleStyle.set(context, Profiles.current?.id, subSize, box) } }
|
||||
val subtitles = textTracks()
|
||||
val audio = player.currentTracks.groups.filter { it.type == C.TRACK_TYPE_AUDIO && it.isSupported }
|
||||
val subtitleRows = listOf(TrackRow("Subtitles", "Off", subtitles.none { it.isSelected }) { chooseSubtitle(null, subtitles); subtitlePreference?.value = SUBTITLES_OFF }) +
|
||||
val subtitleRows = listOf(TrackRow("Subtitles", "Off", subtitles.none { it.isSelected }) { chooseSubtitle(null, subtitles); if (atlas == null) subtitlePreference?.value = SUBTITLES_OFF }) +
|
||||
// Capped so the panel always fits the screen, even on a file with dozens of subtitles.
|
||||
subtitles.take(8).mapIndexed { index, group ->
|
||||
val format = group.getTrackFormat(0)
|
||||
TrackRow("Subtitles", trackLabel(format.label, format.language, index), group.isSelected) { chooseSubtitle(index, subtitles); subtitlePreference?.value = format.language.orEmpty() }
|
||||
TrackRow("Subtitles", trackLabel(format.label, format.language, index), group.isSelected) { chooseSubtitle(index, subtitles); if (atlas == null) subtitlePreference?.value = format.language.orEmpty() }
|
||||
}
|
||||
val audioRows = audio.take(5).mapIndexed { index, group ->
|
||||
val format = group.getTrackFormat(0)
|
||||
@@ -235,7 +258,8 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
var joinedSchedule = runningPlayer != null
|
||||
if (player.playbackState == Player.STATE_READY) ready = true
|
||||
// Its tracks were found before this listener arrived, so the subtitle choice is made here.
|
||||
if (runningPlayer != null && subtitleIndex == null) {
|
||||
if (runningPlayer != null && atlas != null && !atlasApplied && player.currentTracks.groups.isNotEmpty()) applyAtlas(atlas)
|
||||
else if (runningPlayer != null && atlas == null && subtitleIndex == null) {
|
||||
val available = textTracks()
|
||||
subtitleChoice(latestSubtitles?.value, audioLanguages(), available.map { it.getTrackFormat(0).language.orEmpty() }).let { chooseSubtitle(it, available) }
|
||||
}
|
||||
@@ -316,7 +340,8 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
failure = "This programme won't play on this box. Orbit moves on at ${clock(scheduled.programme.endMs)}."
|
||||
return
|
||||
}
|
||||
if (subtitleIndex == null) {
|
||||
if (atlas != null) { if (!atlasApplied && tracks.groups.isNotEmpty()) applyAtlas(atlas) }
|
||||
else if (subtitleIndex == null) {
|
||||
val available = textTracks()
|
||||
subtitleChoice(latestSubtitles?.value, audioLanguages(), available.map { it.getTrackFormat(0).language.orEmpty() }).let { chooseSubtitle(it, available) }
|
||||
}
|
||||
|
||||
@@ -192,7 +192,8 @@ private fun GuideLivePlayer(session: EmbySampleSession, plan: EmbyPlaybackPlan,
|
||||
ExoPlayer.Builder(context, programmeRenderers(context)).setLoadControl(programmeLoadControl()).setMediaSourceFactory(DefaultMediaSourceFactory(factory, OrbitExtractorsFactory())).build().apply {
|
||||
setMediaItem(channelMediaItem(plan))
|
||||
seekTo(programme.offsetAt(System.currentTimeMillis()))
|
||||
trackSelectionParameters = trackSelectionParameters.buildUpon().setPreferredAudioLanguage("en").build()
|
||||
// ATLAS plays its original sound in the picture too (AtlasPlayback); every other channel prefers English as before.
|
||||
trackSelectionParameters = trackSelectionParameters.buildUpon().setPreferredAudioLanguage(AtlasPlayback.forProgramme(channelNumber, plan.item.title)?.original ?: "en").build()
|
||||
prepare(); playWhenReady = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
/** ATLAS's original sound and full English subtitles (Paul, 24 November 2026), with the real track lists from the library. */
|
||||
class AtlasPlaybackTest {
|
||||
private fun t(lang: String?, label: String? = null, forced: Boolean = false) = AtlasTrack(lang, label, forced)
|
||||
|
||||
@Test fun onlyAtlasAndOnlyRecordedTitles() {
|
||||
assertNull(AtlasPlayback.forProgramme(112, "Squid Game / S1 E1 / Red Light, Green Light"))
|
||||
assertNull(AtlasPlayback.forProgramme(null, "Squid Game / S1 E1 / Red Light, Green Light"))
|
||||
assertNull(AtlasPlayback.forProgramme(ATLAS_NUMBER, "A Title Nobody Recorded / S1 E1 / One"))
|
||||
assertEquals(AtlasTracks("ko", true), AtlasPlayback.forProgramme(ATLAS_NUMBER, "Squid Game / S1 E1 / Red Light, Green Light"))
|
||||
assertEquals(AtlasTracks("en", true), AtlasPlayback.forProgramme(ATLAS_NUMBER, "Shōgun / S1 E1 / Anjin"))
|
||||
}
|
||||
|
||||
@Test fun squidGameSkipsTheGermanDefaultAndTheEnglishDub() {
|
||||
// Squid Game S1 E1 as the server lists it: German default, then Korean, then the English dub; forced tracks first.
|
||||
val rule = AtlasPlayback.forProgramme(ATLAS_NUMBER, "Squid Game / S1 E1 / Red Light, Green Light")!!
|
||||
val audio = listOf(t("de", "German"), t("ko", "Korean"), t("en", "English"))
|
||||
val subs = listOf(t("de", "German (Forced)", true), t("de", "German"), t("en", "English (Forced)", true), t("en", "English"), t("en", "English (SDH)"))
|
||||
assertEquals(1, AtlasPlayback.audioIndex(rule, audio))
|
||||
assertEquals(3, AtlasPlayback.subtitleIndex(rule, subs))
|
||||
assertTrue(AtlasPlayback.playable(rule, audio, subs))
|
||||
}
|
||||
|
||||
@Test fun cableGirlsSkipsThePortugueseDefault() {
|
||||
val rule = AtlasPlayback.forProgramme(ATLAS_NUMBER, "Cable Girls / S1 E1 / Dreams")!!
|
||||
val audio = listOf(t("pt", "Brazil"), t("es"))
|
||||
val subs = listOf(t("pt", "Brazil (Forced)", true), t("es", "Forced", true), t("en"), t("en", "SDH"))
|
||||
assertEquals(1, AtlasPlayback.audioIndex(rule, audio))
|
||||
assertEquals(2, AtlasPlayback.subtitleIndex(rule, subs))
|
||||
}
|
||||
|
||||
@Test fun anSdhTrackServesWhenItIsTheOnlyFullOne() {
|
||||
// The 8 Show: German default and forced ASS, then a German full track and an English SDH track.
|
||||
val rule = AtlasPlayback.forProgramme(ATLAS_NUMBER, "The 8 Show / S1 E1 / Episode 1")!!
|
||||
val subs = listOf(t("de", "Forced", true), t("de", "Full"), t("en", "SDH"))
|
||||
assertEquals(2, AtlasPlayback.subtitleIndex(rule, subs))
|
||||
}
|
||||
|
||||
@Test fun forcedOnlyEnglishOrNoOriginalSoundIsNotPlayable() {
|
||||
val rule = AtlasPlayback.forProgramme(ATLAS_NUMBER, "Money Heist / S1 E1 / Episode 1")!!
|
||||
assertFalse(AtlasPlayback.playable(rule, listOf(t("es")), listOf(t("en", "English (Forced)", true), t("en", "Forced"))))
|
||||
assertFalse(AtlasPlayback.playable(rule, listOf(t("en"), t("fr")), listOf(t("en"))))
|
||||
assertTrue(AtlasPlayback.playable(rule, listOf(t("spa")), listOf(t("eng"))))
|
||||
}
|
||||
|
||||
@Test fun languageCodesInEveryForm() {
|
||||
listOf("ko", "kor", "KO-kr", "kr").forEach { assertEquals("ko", AtlasPlayback.language(it)) }
|
||||
listOf("zh", "chi", "zho", "cmn", "yue").forEach { assertEquals("zh", AtlasPlayback.language(it)) }
|
||||
assertEquals("hi", AtlasPlayback.language("hin"))
|
||||
assertNull(AtlasPlayback.language("und"))
|
||||
assertNull(AtlasPlayback.language(null))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assume.assumeTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.time.DayOfWeek
|
||||
import java.time.ZoneId
|
||||
|
||||
/**
|
||||
* ATLAS proposal (Paul, 24 November 2026): plans a first week with the real weighted planner from a pool and block list
|
||||
* written by the audit (ATLAS_WEEK=<dir> holding episodes-113.json and parts.json). A preview only: nothing is installed.
|
||||
*/
|
||||
class AtlasWeekPreviewTest {
|
||||
@Test fun previewTheFirstWeek() {
|
||||
val dir = System.getenv("ATLAS_WEEK")?.let(::File)
|
||||
assumeTrue(dir != null && dir.isDirectory)
|
||||
val pool = ScheduleStore(dir!!).loadPool("8d5f95222bdd4ad3b841f53e18c25056", 113)!!.series
|
||||
val spec = JSONObject(File(dir, "parts.json").readText())
|
||||
val parts = spec.getJSONArray("parts").let { a -> (0 until a.length()).map { i -> a.getJSONObject(i) } }.map { p ->
|
||||
val titles = p.getJSONArray("titles").let { t -> (0 until t.length()).map { t.getString(it) } }
|
||||
val days = p.optJSONArray("days")?.let { d -> (0 until d.length()).map { DayOfWeek.valueOf(d.getString(it)) }.toSet() } ?: emptySet()
|
||||
DayPart(p.getInt("f"), p.getInt("t"), titles, group = p.optString("group"), days = days, onTime = p.optBoolean("onTime"), once = p.optBoolean("once"), key = p.optString("key"))
|
||||
}
|
||||
val tiers = spec.getJSONObject("tiers").let { t -> t.keys().asSequence().associateWith { t.getDouble(it) } }
|
||||
val mixed = spec.getJSONArray("mixed").let { m -> (0 until m.length()).map { m.getString(it) }.toSet() }
|
||||
val zone = ZoneId.of("Europe/London")
|
||||
val from = java.time.LocalDate.of(2026, 11, 30).atStartOfDay(zone).toInstant().toEpochMilli()
|
||||
val plan = extendByBlock(pool, ScheduleCursor(), from, from + 7 * 24 * 60 * 60_000L, { tiers[it.title] ?: TIER_CORE }, parts, zone, { _, _, _ -> false },
|
||||
false, { it.title in mixed }, true, stories = true)
|
||||
File(dir, "week.tsv").writeText(plan.entries.joinToString("\n") { e ->
|
||||
val t = java.time.Instant.ofEpochMilli(e.startMs).atZone(zone)
|
||||
"${t.dayOfWeek}\t${t.toLocalTime()}\t${e.media.durationMs / 60_000}\t${e.media.item.title}\t${e.why.substringBefore(";")}\t${e.presentation}"
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user