bypass range cache for mkv playback

This commit is contained in:
dirtydishes 2026-05-26 00:56:24 -04:00
parent adda8b7b02
commit 46a52b533f
5 changed files with 185 additions and 0 deletions

View file

@ -272,6 +272,9 @@ final class HTTPRangeRemoteFetcher {
guard !url.path.lowercased().hasSuffix(".m3u8") else {
return HTTPRangeProbeResult(isCacheable: false, contentLength: nil, fallbackReason: "hls-playlist")
}
guard !Self.shouldBypassCache(for: url) else {
return HTTPRangeProbeResult(isCacheable: false, contentLength: nil, fallbackReason: "tail-index-container")
}
if let head = try? await response(for: request(method: "HEAD")),
(200..<400).contains(head.statusCode) {
@ -330,6 +333,11 @@ final class HTTPRangeRemoteFetcher {
private func header(_ name: String, in response: HTTPURLResponse) -> String? {
response.value(forHTTPHeaderField: name)
}
private static func shouldBypassCache(for url: URL) -> Bool {
let extensionName = url.pathExtension.lowercased()
return ["mkv", "mk3d", "mka", "mks", "webm"].contains(extensionName)
}
}
enum HTTPRangeCacheError: Error {