feat: select Miruro playback and caption providers

This commit is contained in:
2026-10-22 18:45:14 +02:00
parent 4576080955
commit 80d9e705e5
10 changed files with 561 additions and 76 deletions
+29 -1
View File
@@ -128,6 +128,31 @@ struct ConfigurationChecks {
"printed TOML is directly usable and preserves all default behavior and bindings")
try require(!defaults.showBufferInfo && !defaults.automaticQuality && defaults.snapToEdges,
"built-in defaults hide buffer info, disable automatic quality, and enable snapping")
try require(defaults.miruroVideoProvider.isEmpty && defaults.miruroCaptionProvider.isEmpty,
"Miruro defaults select automatic video and captions independently")
let miruro = root.appendingPathComponent("miruro.toml")
for (settings, video, captions) in [
("video_provider = \"new-Host_2\"", "new-Host_2", ""),
("caption_provider = \"moon\"", "", "moon"),
("video_provider = \"sun\"\ncaption_provider = \"moon\"", "sun", "moon"),
("video_provider = \"\"\ncaption_provider = \"\"", "", ""),
("video_provider = \"\(String(repeating: "a", count: 128))\"", String(repeating: "a", count: 128), "")
] {
try Data("[miruro]\n\(settings)\n".utf8).write(to: miruro)
try require(try PlayerConfiguration.load(from: miruro)
== PlayerConfiguration(miruroVideoProvider: video, miruroCaptionProvider: captions),
"partial Miruro settings preserve omitted defaults and accept runtime provider names")
}
for key in ["video_provider", "caption_provider"] {
for name in ["with space", " sun", "sun ", "é", "host.name", "host/name", String(repeating: "a", count: 129)] {
try Data("[miruro]\n\(key) = \"\(name)\"\n".utf8).write(to: miruro)
try requireLoadError(at: miruro, "invalid Miruro provider")
}
for value in ["true", "1", "[\"sun\"]", "{}"] {
try Data("[miruro]\n\(key) = \(value)\n".utf8).write(to: miruro)
try requireLoadError(at: miruro, "non-string Miruro provider")
}
}
for (value, expected) in [("time", CompactTitleProgress.time), ("percentage", .percentage), ("none", .none)] {
let progress = root.appendingPathComponent("compact-progress-\(value).toml")
try Data("[ui]\ncompact_title_progress = \"\(value)\"\n".utf8).write(to: progress)
@@ -204,7 +229,7 @@ struct ConfigurationChecks {
try require(try PlayerConfiguration.load(from: nested).keys == expectedKeys && keySession.keys == defaults.keys,
"key session overrides never persist")
let emptySections = root.appendingPathComponent("empty-sections.toml")
try Data("[ui]\n[keys]\n[playback]\n".utf8).write(to: emptySections)
try Data("[ui]\n[keys]\n[playback]\n[miruro]\n".utf8).write(to: emptySections)
try require(try PlayerConfiguration.load(from: emptySections) == defaults, "empty nested sections use defaults")
let reordered = root.appendingPathComponent("reordered.toml")
try Data("""
@@ -226,6 +251,9 @@ struct ConfigurationChecks {
("syntax", "[playback]\nautomatic_quality = [\n", ["automatic_quality"]),
("duplicate", "[playback]\nautomatic_quality = true\n\"automatic_quality\" = false\n", ["automatic_quality"]),
("unknown", "unknown_setting = true\n", ["unknown_setting"]),
("miruro-scalar", "miruro = true\n", ["miruro"]),
("miruro-unknown", "[miruro]\nprovider = \"sun\"\n", ["miruro.provider"]),
("miruro-nested", "[miruro.video_provider]\nname = \"sun\"\n", []),
("legacy-buffer", "show_buffer_info = true\n", ["show_buffer_info"]),
("legacy-snap", "snap_to_edges = false\n", ["snap_to_edges"]),
("legacy-quality", "automatic_quality = true\n", ["automatic_quality"]),