mirror of
https://github.com/yattee/yattee.git
synced 2026-06-04 22:04:19 +00:00
Wire Yattee Server playback through /proxy/relay when proxiesVideos is on
The Sources -> Edit Source -> Proxy toggle now renders for Yattee Server entries (supportsVideoProxying gains .yatteeServer). When the toggle is on, playback fetches go through videoWithProxyStreamsAndCaptionsAndStoryboards with mode .relay, so the server returns signed /proxy/relay URLs (byte-relay, supports HTTP Range, no on-disk caching). Downloads keep going through mode .download so the server-side /proxy/fast/ flow continues to cache files for repeat use. InvidiousAPI.proxyStreamsIfNeeded early-returns for .yatteeServer since proxying is now done at fetch time via ?proxy=true rather than client-side host rewriting.
This commit is contained in:
@@ -243,21 +243,23 @@ actor ContentService: ContentServiceProtocol {
|
||||
try await api(for: instance).channelSearch(id: id, query: query, instance: instance, page: page)
|
||||
}
|
||||
|
||||
/// Fetches streams with proxy URLs for faster LAN downloads (Yattee Server only).
|
||||
/// For other backends, returns regular streams.
|
||||
/// Fetches streams with proxy URLs for downloads (Yattee Server: hits /proxy/fast/
|
||||
/// so the server caches the file on disk; other backends apply Invidious URL rewriting).
|
||||
func proxyStreams(videoID: String, instance: Instance) async throws -> [Stream] {
|
||||
if instance.type == .yatteeServer {
|
||||
return try await yatteeServerAPI(for: instance).proxyStreams(videoID: videoID, instance: instance)
|
||||
return try await yatteeServerAPI(for: instance)
|
||||
.proxyStreams(videoID: videoID, instance: instance, mode: .download)
|
||||
}
|
||||
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, applies Invidious proxy rewriting if enabled.
|
||||
/// Fetches video details + streams for downloads. For Yattee Server this routes
|
||||
/// through `/proxy/fast/`, which caches the file on disk on the server.
|
||||
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 yatteeServerAPI(for: instance)
|
||||
.videoWithProxyStreamsAndCaptionsAndStoryboards(id: id, instance: instance, mode: .download)
|
||||
}
|
||||
var result = try await videoWithStreamsAndCaptionsAndStoryboards(id: id, instance: instance)
|
||||
result.streams = await InvidiousAPI.proxyStreamsIfNeeded(result.streams, instance: instance)
|
||||
@@ -278,6 +280,15 @@ actor ContentService: ContentServiceProtocol {
|
||||
case .invidious:
|
||||
return try await invidiousAPI(for: instance).videoWithStreamsAndCaptionsAndStoryboards(id: id, instance: instance)
|
||||
case .yatteeServer:
|
||||
// When the user has opted into proxying for this Yattee Server source,
|
||||
// fetch playback streams through the server's /proxy/relay byte-relay
|
||||
// (Range-friendly, fast TTFB). When off, leave routing to the server's
|
||||
// per-site proxy_streaming flag — the server can still proxy by default,
|
||||
// but the client doesn't force it on top.
|
||||
if instance.proxiesVideos {
|
||||
return try await yatteeServerAPI(for: instance)
|
||||
.videoWithProxyStreamsAndCaptionsAndStoryboards(id: id, instance: instance, mode: .relay)
|
||||
}
|
||||
return try await yatteeServerAPI(for: instance).videoWithStreamsAndCaptionsAndStoryboards(id: id, instance: instance)
|
||||
case .piped:
|
||||
// Piped fallback - make separate calls (no storyboard support)
|
||||
|
||||
Reference in New Issue
Block a user