feat: add Chromecast playback support
This commit is contained in:
@@ -24,6 +24,13 @@ struct WebVTTDocument: Sendable {
|
||||
}
|
||||
|
||||
static func load(url: String, headers: String) async throws -> WebVTTDocument {
|
||||
let data = try await loadData(url: url, headers: headers)
|
||||
// Providers sometimes disguise VTT resources as images: trust the explicit format and content.
|
||||
guard let text = String(data: data, encoding: .utf8) else { throw SubtitleError.content }
|
||||
return try parse(text)
|
||||
}
|
||||
|
||||
static func loadData(url: String, headers: String) async throws -> Data {
|
||||
let request = try request(url: url, headers: headers)
|
||||
let configuration = URLSessionConfiguration.ephemeral
|
||||
configuration.timeoutIntervalForRequest = 15
|
||||
@@ -51,10 +58,7 @@ struct WebVTTDocument: Sendable {
|
||||
if Task.isCancelled { throw CancellationError() }
|
||||
throw SubtitleError.transport
|
||||
}
|
||||
// Providers sometimes disguise VTT resources as images: trust the explicit format and content,
|
||||
// never the path extension or Content-Type.
|
||||
guard let text = String(data: data, encoding: .utf8) else { throw SubtitleError.content }
|
||||
return try parse(text)
|
||||
return data
|
||||
}
|
||||
|
||||
static func parse(_ text: String) throws -> WebVTTDocument {
|
||||
|
||||
Reference in New Issue
Block a user