mirror of
https://github.com/dirtydishes/dreamio.git
synced 2026-06-06 21:38:15 +00:00
keep stremio subtitle loads untouched
This commit is contained in:
parent
dc11afc45f
commit
6a29dde857
5 changed files with 196 additions and 8 deletions
|
|
@ -129,7 +129,7 @@ enum SubtitleCandidateParser {
|
|||
if let candidate = candidate(from: dictionary) {
|
||||
results.append(candidate)
|
||||
}
|
||||
dictionary.values.forEach { collect(from: $0, into: &results) }
|
||||
orderedNestedValues(in: dictionary).forEach { collect(from: $0, into: &results) }
|
||||
case let array as [Any]:
|
||||
array.forEach { collect(from: $0, into: &results) }
|
||||
case let string as String:
|
||||
|
|
@ -159,6 +159,27 @@ enum SubtitleCandidateParser {
|
|||
)
|
||||
}
|
||||
|
||||
private static func orderedNestedValues(in dictionary: [String: Any]) -> [Any] {
|
||||
let preferredKeys = ["subtitles", "subtitle", "files", "downloads", "download"]
|
||||
var visitedKeys = Set<String>()
|
||||
var values: [Any] = []
|
||||
|
||||
preferredKeys.forEach { key in
|
||||
if let value = dictionary[key] {
|
||||
values.append(value)
|
||||
visitedKeys.insert(key)
|
||||
}
|
||||
}
|
||||
|
||||
dictionary.keys
|
||||
.filter { !visitedKeys.contains($0) && !urlFields.contains($0) }
|
||||
.sorted()
|
||||
.compactMap { dictionary[$0] }
|
||||
.forEach { values.append($0) }
|
||||
|
||||
return values
|
||||
}
|
||||
|
||||
private static func subtitleURL(from string: String?) -> URL? {
|
||||
guard let string,
|
||||
let url = URL(string: string),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue