invidious-companion-patches/patches/0002-feat-add-support-for-an-external-videoplayback-proxy.patch
Fijxu 51e0983d82
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m17s
update patches
2025-03-31 19:48:19 -03:00

72 lines
2.9 KiB
Diff

From 2028045428f15eb7a9a21cd438b44c110fad6b2d Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 18:44:10 -0300
Subject: [PATCH 02/12] feat: add support for an external videoplayback proxy
---
config/config.example.toml | 1 +
src/lib/helpers/config.ts | 3 +++
src/routes/invidious_routes/dashManifest.ts | 6 ++++--
src/routes/invidious_routes/latestVersion.ts | 3 ++-
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/config/config.example.toml b/config/config.example.toml
index 5989656..0b4d7b8 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -27,6 +27,7 @@
# #proxy = "" # env variable: PROXY
# # Enable YouTube new video format UMP
# ump = false
+# external_videoplayback_proxy = ""
###
# Network call timeouts when talking to YouTube.
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index 426426f..273fe95 100644
--- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts
@@ -29,6 +29,9 @@ const ConfigSchema = z.object({
debounce_multiplier: z.number().optional(),
}).strict().optional(),
}).strict().optional(),
+ external_videoplayback_proxy: z.string().default(
+ Deno.env.get("EXTERNAL_VIDEOPLAYBACK_PROXY") || "",
+ ),
}).strict().default({}),
jobs: z.object({
youtube_session: z.object({
diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts
index 3834601..d69f1cf 100644
--- a/src/routes/invidious_routes/dashManifest.ts
+++ b/src/routes/invidious_routes/dashManifest.ts
@@ -91,8 +91,10 @@ dashManifest.get("/:videoId", async (c) => {
queryParams.set("enc", "true");
queryParams.set("data", encryptedParams);
}
- dashUrl = (dashUrl.pathname + "?" +
- queryParams.toString()) as unknown as URL;
+ dashUrl =
+ (config.networking.external_videoplayback_proxy +
+ dashUrl.pathname + "?" +
+ queryParams.toString()) as unknown as URL;
return dashUrl;
} else {
return dashUrl;
diff --git a/src/routes/invidious_routes/latestVersion.ts b/src/routes/invidious_routes/latestVersion.ts
index 6421904..07b070a 100644
--- a/src/routes/invidious_routes/latestVersion.ts
+++ b/src/routes/invidious_routes/latestVersion.ts
@@ -83,7 +83,8 @@ latestVersion.get("/", async (c) => {
queryParams.set("enc", "true");
queryParams.set("data", encryptedParams);
}
- urlToRedirect = itagUrlParsed.pathname + "?" +
+ urlToRedirect = config.networking.external_videoplayback_proxy +
+ itagUrlParsed.pathname + "?" +
queryParams.toString();
}
--
2.49.0