mirror of
https://github.com/dirtydishes/dreamio.git
synced 2026-06-06 13:37:24 +00:00
forward late subtitles to native player
This commit is contained in:
parent
66f66faf28
commit
d6bcb52e8a
8 changed files with 729 additions and 7 deletions
|
|
@ -9,6 +9,8 @@ struct StreamResolverTests {
|
|||
testRedactorHandlesPercentEncodedPath()
|
||||
testPlaybackTimeFormatting()
|
||||
testSubtitleCandidateParsing()
|
||||
testOpenSubtitlesV3CandidateParsing()
|
||||
testSubtitleCandidateDeduplicationPreservesLabels()
|
||||
testSubtitleOptionMappingIncludesNone()
|
||||
print("StreamResolverTests passed")
|
||||
}
|
||||
|
|
@ -110,6 +112,65 @@ struct StreamResolverTests {
|
|||
assertEqual(candidates[2].url.absoluteString, "https://cdn.example.test/movie.fr.ass?download=1")
|
||||
}
|
||||
|
||||
private static func testOpenSubtitlesV3CandidateParsing() {
|
||||
let payload: [String: Any] = [
|
||||
"subtitles": [
|
||||
[
|
||||
"language": "English",
|
||||
"download": "https://api.opensubtitles.com/api/v1/download/subtitle-file",
|
||||
"nested": [
|
||||
[
|
||||
"file": "https://dl.opensubtitles.org/en/subtitle.vtt?download=1"
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
"lang": "spa",
|
||||
"url": "https://opensubtitles.example.test/download/episode.srt"
|
||||
]
|
||||
],
|
||||
"body": "alternate https://cdn.example.test/from-string.ass?source=opensubtitles",
|
||||
"ignored": [
|
||||
"https://cdn.example.test/poster.jpg",
|
||||
["file": "https://cdn.example.test/video.mkv"]
|
||||
]
|
||||
]
|
||||
|
||||
let candidates = SubtitleCandidateParser.candidates(in: payload)
|
||||
|
||||
assertEqual(candidates.count, 4)
|
||||
assertEqual(candidates[0].label, "English")
|
||||
assertEqual(candidates[0].language, "English")
|
||||
assertEqual(candidates[1].url.absoluteString, "https://dl.opensubtitles.org/en/subtitle.vtt?download=1")
|
||||
assertEqual(candidates[2].label, "spa")
|
||||
assertEqual(candidates[2].language, "spa")
|
||||
assertEqual(candidates[3].url.absoluteString, "https://cdn.example.test/from-string.ass?source=opensubtitles")
|
||||
}
|
||||
|
||||
private static func testSubtitleCandidateDeduplicationPreservesLabels() {
|
||||
let payload: [String: Any] = [
|
||||
"subtitles": [
|
||||
[
|
||||
"label": "English SDH",
|
||||
"lang": "eng",
|
||||
"url": "https://opensubtitles.example.test/download/duplicate.srt"
|
||||
],
|
||||
[
|
||||
"label": "Duplicate",
|
||||
"language": "English",
|
||||
"download": "https://opensubtitles.example.test/download/duplicate.srt"
|
||||
],
|
||||
"https://opensubtitles.example.test/download/duplicate.srt"
|
||||
]
|
||||
]
|
||||
|
||||
let candidates = SubtitleCandidateParser.candidates(in: payload)
|
||||
|
||||
assertEqual(candidates.count, 1)
|
||||
assertEqual(candidates[0].label, "English SDH")
|
||||
assertEqual(candidates[0].language, "eng")
|
||||
}
|
||||
|
||||
private static func testSubtitleOptionMappingIncludesNone() {
|
||||
let options = SubtitleOptionMapper.options(from: [
|
||||
SubtitleTrack(id: 2, name: "English"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue