Apply Invidious proxy rewriting to download streams

Downloads were using direct YouTube CDN URLs even when proxiesVideos
was enabled. Apply the same proxyStreamsIfNeeded used by the player
to the download code path in ContentService.
This commit is contained in:
Arkadiusz Fal
2026-02-18 20:59:12 +01:00
parent d8f9d24a82
commit 5f304ceb5c

View File

@@ -254,16 +254,19 @@ actor ContentService: ContentServiceProtocol {
if instance.type == .yatteeServer {
return try await yatteeServerAPI(for: instance).proxyStreams(videoID: videoID, instance: instance)
}
return try await streams(videoID: videoID, instance: instance)
let fetchedStreams = try await streams(videoID: videoID, instance: instance)
return await InvidiousAPI.proxyStreamsIfNeeded(fetchedStreams, instance: instance)
}
/// Fetches video details, proxy streams, captions, and storyboards (Yattee Server only).
/// For other backends, falls back to regular streams.
/// For other backends, applies Invidious proxy rewriting if enabled.
func videoWithProxyStreamsAndCaptionsAndStoryboards(id: String, instance: Instance) async throws -> (video: Video, streams: [Stream], captions: [Caption], storyboards: [Storyboard]) {
if instance.type == .yatteeServer {
return try await yatteeServerAPI(for: instance).videoWithProxyStreamsAndCaptionsAndStoryboards(id: id, instance: instance)
}
return try await videoWithStreamsAndCaptionsAndStoryboards(id: id, instance: instance)
var result = try await videoWithStreamsAndCaptionsAndStoryboards(id: id, instance: instance)
result.streams = await InvidiousAPI.proxyStreamsIfNeeded(result.streams, instance: instance)
return result
}
/// Fetches video details, streams, and captions in a single API call (Invidious and Yattee Server).