App v0.2.26 and gateway 0.1.20

Client: seek controls, Bazarr subtitle download and cast panel in the
player; MDBList ratings strip; episode and schedule detail pages; series
pace estimate; what's new panel; install-permission onboarding step;
synced per-profile preferences; Emby outage banner.

Gateway: rebuilt admin console (one fragment per page), preference
history and restore, merged Continue Watching, Emby health probe,
subtitle selection and Bazarr download, structured request logging with
per-request identity, and embedded build version.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
ponzischeme89
2026-08-06 22:33:56 +12:00
co-authored by Claude Opus 5
parent 2675e6d82b
commit 4a4df7a73c
257 changed files with 24868 additions and 3108 deletions
+96
View File
@@ -0,0 +1,96 @@
package api
import "testing"
func TestNormalizeSubtitleLanguage(t *testing.T) {
cases := map[string]string{
"ita": "it",
"ITA": "it",
" it ": "it",
"fre": "fr",
"fra": "fr",
"pt-BR": "pt",
"zho": "zh",
"": "",
// Unknown codes survive as themselves so an exact match still works for a
// language the catalogue has no entry for.
"klingon": "klingon",
}
for input, want := range cases {
if got := normalizeSubtitleLanguage(input); got != want {
t.Fatalf("normalizeSubtitleLanguage(%q) = %q, want %q", input, got, want)
}
}
}
func TestSubtitleLanguageOptionsAreLegalPreferenceValues(t *testing.T) {
definition, ok := preferenceDefinitionFor("subtitleLanguage")
if !ok {
t.Fatal("subtitleLanguage is missing from the catalogue")
}
if got := normalizePreference(definition, "it"); got != "it" {
t.Fatalf("Italian was rejected by the catalogue: %v", got)
}
if got := normalizePreference(definition, "nonsense"); got != subtitleLanguageAuto {
t.Fatalf("an illegal language became %v, want the default", got)
}
if got := normalizePreferences(map[string]any{})["subtitlesEnabled"]; got != true {
t.Fatalf("subtitlesEnabled defaulted to %v, want true", got)
}
}
func TestSelectSubtitleOffMeansOff(t *testing.T) {
subtitles := []playableSubtitle{{ID: "1", Language: "eng", IsDefault: true}}
if got := selectSubtitle(subtitles, false, "en"); got != "" {
t.Fatalf("selected %q with subtitles turned off", got)
}
}
func TestSelectSubtitlePrefersChosenLanguage(t *testing.T) {
subtitles := []playableSubtitle{
{ID: "1", Language: "eng", IsDefault: true},
{ID: "2", Language: "ita", IsForced: true},
{ID: "3", Language: "ita", IsHearingImpaired: true},
{ID: "4", Language: "ita"},
}
// The full Italian track, not the forced one that comes first and not the SDH one.
if got := selectSubtitle(subtitles, true, "it"); got != "4" {
t.Fatalf("selectSubtitle picked %q, want the full Italian track", got)
}
}
func TestSelectSubtitleMissingLanguageFallsBackToForcedOnly(t *testing.T) {
withForced := []playableSubtitle{
{ID: "1", Language: "eng", IsDefault: true},
{ID: "2", Language: "eng", IsForced: true},
}
if got := selectSubtitle(withForced, true, "it"); got != "2" {
t.Fatalf("selectSubtitle picked %q, want the forced track", got)
}
// No forced track and no Italian: nothing, rather than English the viewer never asked
// for.
withoutForced := []playableSubtitle{{ID: "1", Language: "eng", IsDefault: true}}
if got := selectSubtitle(withoutForced, true, "it"); got != "" {
t.Fatalf("selectSubtitle picked %q, want nothing", got)
}
}
func TestSelectSubtitleAutomaticKeepsFlagOrder(t *testing.T) {
subtitles := []playableSubtitle{
{ID: "1", Language: "eng"},
{ID: "2", Language: "eng", IsDefault: true},
{ID: "3", Language: "eng", IsForced: true},
}
if got := selectSubtitle(subtitles, true, subtitleLanguageAuto); got != "3" {
t.Fatalf("automatic picked %q, want the forced track", got)
}
if got := selectSubtitle(subtitles[:2], true, ""); got != "2" {
t.Fatalf("automatic picked %q, want the default track", got)
}
if got := selectSubtitle(subtitles[:1], true, subtitleLanguageAuto); got != "1" {
t.Fatalf("automatic picked %q, want the only track", got)
}
if got := selectSubtitle(nil, true, subtitleLanguageAuto); got != "" {
t.Fatalf("automatic picked %q with no tracks", got)
}
}