invidious-companion-patches/patches/0017-option-to-only-use-http-1.1-client-on-videoplayback-.patch
Fijxu 0f8f95b87e
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 12s
add 0018 and 0019
2025-04-22 15:43:05 -04:00

55 lines
1.8 KiB
Diff

From e4952342e5dd29daf1b69b479c9e5ebd7722a1e9 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net>
Date: Mon, 21 Apr 2025 16:53:15 -0400
Subject: [PATCH 17/19] option to only use http/1.1 client on videoplayback
requests
---
src/lib/helpers/config.ts | 6 ++++++
src/routes/videoPlaybackProxy.ts | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index acb04bb..602e460 100644
--- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts
@@ -46,6 +46,12 @@ export const ConfigSchema = z.object({
max_proxy_retries: z.number().default(
Number(Deno.env.get("MAX_PROXY_RETIRES") || 5),
),
+ h1VPClient: z.boolean().default(
+ Deno.env.get("NETWORKING_H1VPCLIENT") ===
+ "false"
+ ? false
+ : true,
+ ),
}).strict().default({}),
jobs: z.object({
youtube_session: z.object({
diff --git a/src/routes/videoPlaybackProxy.ts b/src/routes/videoPlaybackProxy.ts
index 0f707d9..2af343e 100644
--- a/src/routes/videoPlaybackProxy.ts
+++ b/src/routes/videoPlaybackProxy.ts
@@ -18,6 +18,11 @@ const { getFetchClient } = await import(getFetchClientLocation);
const videoPlaybackProxy = new Hono();
+const h1client = Deno.createHttpClient({
+ http1: true,
+ http2: false,
+});
+
videoPlaybackProxy.options("/", () => {
const headersForResponse: Record<string, string> = {
"access-control-allow-origin": "*",
@@ -134,6 +139,7 @@ videoPlaybackProxy.get("/", async (c) => {
method: "POST",
body: new Uint8Array([0x78, 0]), // protobuf: { 15: 0 } (no idea what it means but this is what YouTube uses),
headers: headersToSend,
+ client: config.networking.h1VPClient ? h1client : undefined,
},
);
--
2.49.0