- Migration wizard from Sonarr/Radarr/Prowlarr (unarr migrate) [pre-beta] - Auto-detect instances via Docker, config files, port scan, Prowlarr - Import wanted list (monitored+missing movies/series) - Import download history and blocklist to avoid re-downloading - Extract debrid tokens from *arr download clients - Quality profile mapping to preferred_quality config - DISTINCT ON PostgreSQL query for optimal torrent selection - JSON export with --dry-run --json (text to stderr, JSON to stdout) - Media server detection (Plex/Jellyfin/Emby) in unarr init - Detects library paths and offers them as download directory options - Debrid auto-configuration in unarr init - Scans *arr instances for debrid tokens - Validates and saves via API if user confirms - New preferred_quality setting in config (2160p/1080p/720p) - Library scan command (unarr scan) with ffprobe metadata extraction
64 lines
1.3 KiB
Go
64 lines
1.3 KiB
Go
package mediainfo
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeLang(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
want string
|
|
}{
|
|
{"", "und"},
|
|
{"eng", "en"},
|
|
{"spa", "es"},
|
|
{"fre", "fr"},
|
|
{"fra", "fr"},
|
|
{"ger", "de"},
|
|
{"deu", "de"},
|
|
{"en", "en"},
|
|
{"es", "es"},
|
|
{"English", "en"},
|
|
{"SPANISH", "es"},
|
|
{"Japanese", "ja"},
|
|
{"jpn", "ja"},
|
|
{"chi", "zh"},
|
|
{"zho", "zh"},
|
|
{"und", "und"},
|
|
{"xyz", "xyz"}, // unknown → lowercase passthrough
|
|
{"POR", "pt"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.input, func(t *testing.T) {
|
|
got := NormalizeLang(tt.input)
|
|
if got != tt.want {
|
|
t.Errorf("NormalizeLang(%q) = %q, want %q", tt.input, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestComputeLanguages(t *testing.T) {
|
|
tracks := []AudioTrack{
|
|
{Lang: "en", Codec: "aac", Channels: 2},
|
|
{Lang: "es", Codec: "ac3", Channels: 6},
|
|
{Lang: "en", Codec: "dts", Channels: 6}, // duplicate
|
|
{Lang: "und", Codec: "aac", Channels: 2},
|
|
{Lang: "", Codec: "aac", Channels: 2},
|
|
}
|
|
|
|
langs := ComputeLanguages(tracks)
|
|
|
|
if len(langs) != 2 {
|
|
t.Fatalf("expected 2 languages, got %d: %v", len(langs), langs)
|
|
}
|
|
if langs[0] != "en" || langs[1] != "es" {
|
|
t.Errorf("expected [en es], got %v", langs)
|
|
}
|
|
}
|
|
|
|
func TestComputeLanguagesEmpty(t *testing.T) {
|
|
langs := ComputeLanguages(nil)
|
|
if len(langs) != 0 {
|
|
t.Errorf("expected empty, got %v", langs)
|
|
}
|
|
}
|