mirror of
https://github.com/yattee/yattee.git
synced 2026-06-05 06:14:18 +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:
@@ -254,21 +254,36 @@ actor YatteeServerAPI: InstanceAPI {
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Proxy Streams for Downloads
|
||||
// MARK: - Proxy Streams
|
||||
|
||||
/// Fetches streams with URLs that proxy through the Yattee Server for faster LAN downloads.
|
||||
/// The proxy URLs point to the server's /proxy/fast/{video_id}?itag=X endpoint instead of
|
||||
/// directly to YouTube CDN, allowing the server to download at full speed and serve locally.
|
||||
func proxyStreams(videoID: String, instance: Instance) async throws -> [Stream] {
|
||||
let endpoint = GenericEndpoint.get("/api/v1/videos/\(videoID)", query: ["proxy": "true"])
|
||||
/// Selects which yattee-server proxy endpoint stream URLs point at.
|
||||
///
|
||||
/// - `relay`: signed `/proxy/relay` byte-relay — fast TTFB, supports HTTP
|
||||
/// Range, no on-disk caching. Right shape for playback.
|
||||
/// - `download`: legacy `/proxy/fast/{video_id}` — runs yt-dlp on the
|
||||
/// server, writes a file to `/downloads`, then tails it. Right shape
|
||||
/// for downloads since the cached file accelerates repeated requests.
|
||||
enum ProxyMode: String {
|
||||
case relay
|
||||
case download
|
||||
}
|
||||
|
||||
/// Fetches streams with URLs that proxy through the Yattee Server.
|
||||
func proxyStreams(videoID: String, instance: Instance, mode: ProxyMode) async throws -> [Stream] {
|
||||
let endpoint = GenericEndpoint.get(
|
||||
"/api/v1/videos/\(videoID)",
|
||||
query: ["proxy": "true", "proxy_mode": mode.rawValue]
|
||||
)
|
||||
let response: YatteeVideoDetails = try await httpClient.fetch(endpoint, baseURL: instance.url)
|
||||
return response.toStreams()
|
||||
}
|
||||
|
||||
/// Fetches video details, proxy streams, captions, and storyboards in a single API call.
|
||||
/// Use this for downloads to get streams that route through the server.
|
||||
func videoWithProxyStreamsAndCaptionsAndStoryboards(id: String, instance: Instance) async throws -> (video: Video, streams: [Stream], captions: [Caption], storyboards: [Storyboard]) {
|
||||
let endpoint = GenericEndpoint.get("/api/v1/videos/\(id)", query: ["proxy": "true"])
|
||||
func videoWithProxyStreamsAndCaptionsAndStoryboards(id: String, instance: Instance, mode: ProxyMode) async throws -> (video: Video, streams: [Stream], captions: [Caption], storyboards: [Storyboard]) {
|
||||
let endpoint = GenericEndpoint.get(
|
||||
"/api/v1/videos/\(id)",
|
||||
query: ["proxy": "true", "proxy_mode": mode.rawValue]
|
||||
)
|
||||
let response: YatteeVideoDetails = try await httpClient.fetch(endpoint, baseURL: instance.url)
|
||||
return (
|
||||
video: response.toVideo(),
|
||||
|
||||
Reference in New Issue
Block a user