mirror of
https://github.com/dirtydishes/dreamio.git
synced 2026-06-06 13:37:24 +00:00
preserve opensubtitles caption labels
This commit is contained in:
parent
046444f9ad
commit
ae996e7ffb
6 changed files with 628 additions and 5 deletions
|
|
@ -21,6 +21,8 @@ struct StreamResolverTests {
|
|||
await testSubtitleResolverRejectsNonSubtitleAPIResponse()
|
||||
testSubtitleCandidateDeduplicationPreservesLabels()
|
||||
testSubtitleCandidateDeduplicationUpgradesLabels()
|
||||
testSubtitleDisplayNameNormalization()
|
||||
testSubtitleDisplayNameUsesPreservedNamesForGenericVLCTracks()
|
||||
testSubtitleOptionMappingIncludesNone()
|
||||
print("StreamResolverTests passed")
|
||||
}
|
||||
|
|
@ -437,6 +439,56 @@ struct StreamResolverTests {
|
|||
assertEqual(options.first?.id, -1)
|
||||
}
|
||||
|
||||
private static func testSubtitleDisplayNameNormalization() {
|
||||
assertEqual(
|
||||
SubtitleDisplayName.displayName(for: SubtitleCandidate(
|
||||
url: URL(string: "https://opensubtitles.example.test/download/subtitle.srt")!,
|
||||
label: "Track 1",
|
||||
language: "eng"
|
||||
)),
|
||||
"English"
|
||||
)
|
||||
assertEqual(
|
||||
SubtitleDisplayName.displayName(for: SubtitleCandidate(
|
||||
url: URL(string: "https://opensubtitles.example.test/download/subtitle.srt")!,
|
||||
label: "Track 2",
|
||||
language: "Spanish"
|
||||
)),
|
||||
"Spanish"
|
||||
)
|
||||
assertEqual(
|
||||
SubtitleDisplayName.displayName(for: SubtitleCandidate(
|
||||
url: URL(string: "https://opensubtitles.example.test/download/subtitle.srt")!,
|
||||
label: "English SDH",
|
||||
language: "eng"
|
||||
)),
|
||||
"English SDH"
|
||||
)
|
||||
assertEqual(
|
||||
SubtitleDisplayName.displayName(for: SubtitleCandidate(
|
||||
url: URL(string: "https://cdn.example.test/subtitles/movie.es.srt")!,
|
||||
label: "External Subtitle",
|
||||
language: nil
|
||||
)),
|
||||
"movie.es"
|
||||
)
|
||||
}
|
||||
|
||||
private static func testSubtitleDisplayNameUsesPreservedNamesForGenericVLCTracks() {
|
||||
let options = SubtitleOptionMapper.options(from: [
|
||||
SubtitleTrack(
|
||||
id: 3,
|
||||
name: SubtitleDisplayName.name(forVLCTrackName: "Track 1", preservedName: "English")
|
||||
),
|
||||
SubtitleTrack(
|
||||
id: 4,
|
||||
name: SubtitleDisplayName.name(forVLCTrackName: "Commentary", preservedName: "Spanish")
|
||||
)
|
||||
])
|
||||
|
||||
assertEqual(options.map(\.name), ["None", "English", "Commentary"])
|
||||
}
|
||||
|
||||
private static func assertEqual<T: Equatable>(_ actual: T?, _ expected: T, file: StaticString = #file, line: UInt = #line) {
|
||||
assert(actual == expected, "Expected \(String(describing: expected)), got \(String(describing: actual))", file: file, line: line)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue