fix opensubtitles manifest subtitle urls

This commit is contained in:
dirtydishes 2026-05-25 12:18:45 -04:00
parent 07741bae96
commit 6008272d0a
6 changed files with 275 additions and 5 deletions

View file

@ -245,6 +245,9 @@ enum SubtitleCandidateParser {
}
let lowercased = url.absoluteString.lowercased()
if isOpenSubtitlesManifestIdentifier(url) {
return nil
}
guard supportedExtensions.contains(url.pathExtension.lowercased())
|| supportedExtensions.contains(where: { lowercased.contains(".\($0)?") || lowercased.contains(".\($0)&") })
|| lowercased.contains("subtitle")
@ -256,6 +259,14 @@ enum SubtitleCandidateParser {
return url
}
private static func isOpenSubtitlesManifestIdentifier(_ url: URL) -> Bool {
guard url.host?.localizedCaseInsensitiveContains("opensubtitles") == true else {
return false
}
let path = url.path.lowercased()
return path == "/manifest.json" || path.range(of: #"/manifest\.json_\d+$"#, options: .regularExpression) != nil
}
private static func openSubtitlesDownloadURL(from value: Any?) -> URL? {
let id: String?
if let string = value as? String, !string.isEmpty {