update patches and invidious-companion
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m14s

This commit is contained in:
Fijxu 2025-03-27 21:28:16 -03:00
parent cd5f5db2c6
commit a774a714fa
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
15 changed files with 93 additions and 289 deletions

@ -1 +1 @@
Subproject commit 1867045ba9a23250317fcb139bed0364e6d7cd89 Subproject commit f1606a0aa1a8d37df690bf4757a5a6ae4a955a0b

View file

@ -1,19 +1,19 @@
From 91a9fb17566462144f6f54d4a6054077024cc719 Mon Sep 17 00:00:00 2001 From c0209c66dd9381b9a8cee2c832155cf28364faf3 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 19:37:34 -0300 Date: Mon, 24 Mar 2025 19:37:34 -0300
Subject: [PATCH 06/14] ci: update deno to 2.2.4 Subject: [PATCH 01/12] ci: update deno to 2.2.5
--- ---
Dockerfile | 2 +- Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Dockerfile b/Dockerfile diff --git a/Dockerfile b/Dockerfile
index 04b74c0..a6dc150 100644 index 04b74c0..0f9f933 100644
--- a/Dockerfile --- a/Dockerfile
+++ b/Dockerfile +++ b/Dockerfile
@@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
-FROM denoland/deno:debian-2.1.4 AS builder -FROM denoland/deno:debian-2.1.4 AS builder
+FROM denoland/deno:debian-2.2.4 AS builder +FROM denoland/deno:debian-2.2.5 AS builder
ARG TINI_VERSION=0.19.0 ARG TINI_VERSION=0.19.0

View file

@ -1,20 +1,20 @@
From aa4a7282934a6f23dbcb055435f0fac114c3abba Mon Sep 17 00:00:00 2001 From 291d80dcf32824db5175b031b389d9e1552465e4 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 18:44:10 -0300 Date: Mon, 24 Mar 2025 18:44:10 -0300
Subject: [PATCH 01/14] feat: add support for an external videoplayback proxy Subject: [PATCH 02/12] feat: add support for an external videoplayback proxy
--- ---
config/config.example.toml | 1 + config/config.example.toml | 1 +
src/lib/helpers/config.ts | 3 +++ src/lib/helpers/config.ts | 3 +++
src/routes/invidious_routes/dashManifest.ts | 5 +++-- src/routes/invidious_routes/dashManifest.ts | 6 ++++--
src/routes/invidious_routes/latestVersion.ts | 3 ++- src/routes/invidious_routes/latestVersion.ts | 3 ++-
4 files changed, 9 insertions(+), 3 deletions(-) 4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/config/config.example.toml b/config/config.example.toml diff --git a/config/config.example.toml b/config/config.example.toml
index c56b95b..e173e06 100644 index 5989656..0b4d7b8 100644
--- a/config/config.example.toml --- a/config/config.example.toml
+++ b/config/config.example.toml +++ b/config/config.example.toml
@@ -26,6 +26,7 @@ @@ -27,6 +27,7 @@
# #proxy = "" # env variable: PROXY # #proxy = "" # env variable: PROXY
# # Enable YouTube new video format UMP # # Enable YouTube new video format UMP
# ump = false # ump = false
@ -23,10 +23,10 @@ index c56b95b..e173e06 100644
### ###
# Network call timeouts when talking to YouTube. # Network call timeouts when talking to YouTube.
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index edba9da..5ff4a2d 100644 index 426426f..273fe95 100644
--- a/src/lib/helpers/config.ts --- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts +++ b/src/lib/helpers/config.ts
@@ -26,6 +26,9 @@ const ConfigSchema = z.object({ @@ -29,6 +29,9 @@ const ConfigSchema = z.object({
debounce_multiplier: z.number().optional(), debounce_multiplier: z.number().optional(),
}).strict().optional(), }).strict().optional(),
}).strict().optional(), }).strict().optional(),
@ -37,33 +37,34 @@ index edba9da..5ff4a2d 100644
jobs: z.object({ jobs: z.object({
youtube_session: z.object({ youtube_session: z.object({
diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts
index 2b796ba..46756cd 100644 index e816470..930eef1 100644
--- a/src/routes/invidious_routes/dashManifest.ts --- a/src/routes/invidious_routes/dashManifest.ts
+++ b/src/routes/invidious_routes/dashManifest.ts +++ b/src/routes/invidious_routes/dashManifest.ts
@@ -85,8 +85,9 @@ dashManifest.get("/:videoId", async (c) => { @@ -109,8 +109,10 @@ dashManifest.get("/:videoId", async (c) => {
let dashUrl = url; queryParams.set("enc", "true");
if (local) { queryParams.set("data", encryptedParams);
// Can't create URL type without host part
- dashUrl = (dashUrl.pathname + dashUrl.search + "&host=" +
- dashUrl.host) as unknown as URL;
+ dashUrl = config.networking.external_videoplayback_proxy +
+ (dashUrl.pathname + dashUrl.search + "&host=" +
+ dashUrl.host) as unknown as URL;
if (config.networking.ump) {
dashUrl = dashUrl + "&ump=1" as unknown as URL;
} }
- 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 diff --git a/src/routes/invidious_routes/latestVersion.ts b/src/routes/invidious_routes/latestVersion.ts
index 191c0a4..a8ead67 100644 index 6421904..07b070a 100644
--- a/src/routes/invidious_routes/latestVersion.ts --- a/src/routes/invidious_routes/latestVersion.ts
+++ b/src/routes/invidious_routes/latestVersion.ts +++ b/src/routes/invidious_routes/latestVersion.ts
@@ -64,7 +64,8 @@ latestVersion.get("/", async (c) => { @@ -83,7 +83,8 @@ latestVersion.get("/", async (c) => {
const itagUrlParsed = new URL(itagUrl); queryParams.set("enc", "true");
let urlToRedirect = itagUrlParsed.toString(); queryParams.set("data", encryptedParams);
if (local) { }
- urlToRedirect = itagUrlParsed.pathname + itagUrlParsed.search + - urlToRedirect = itagUrlParsed.pathname + "?" +
+ urlToRedirect = config.networking.external_videoplayback_proxy + + urlToRedirect = config.networking.external_videoplayback_proxy +
+ itagUrlParsed.pathname + itagUrlParsed.search + + itagUrlParsed.pathname + "?" +
"&host=" + itagUrlParsed.host; queryParams.toString();
} }
-- --

View file

@ -1,7 +1,7 @@
From f239b39e13926733663ae7a213a59e0d68563609 Mon Sep 17 00:00:00 2001 From 3ac18ddfa246eb421483cfc55120709e203e5e1a Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 18:52:53 -0300 Date: Mon, 24 Mar 2025 18:52:53 -0300
Subject: [PATCH 02/14] feat: report the external videoplayback proxy via /info Subject: [PATCH 03/12] feat: report the external videoplayback proxy via /info
endpoint endpoint
--- ---

View file

@ -1,7 +1,7 @@
From 4a27e15a8ba0d606ced9e14005c41064d3b446a6 Mon Sep 17 00:00:00 2001 From e89236d910bb112204448765055a985dc2a589d5 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 19:02:01 -0300 Date: Mon, 24 Mar 2025 19:02:01 -0300
Subject: [PATCH 03/14] feat: add resolution limit on DASH streams to save Subject: [PATCH 04/12] feat: add resolution limit on DASH streams to save
bandwidth bandwidth
--- ---
@ -11,25 +11,25 @@ Subject: [PATCH 03/14] feat: add resolution limit on DASH streams to save
3 files changed, 10 insertions(+), 1 deletion(-) 3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/config/config.example.toml b/config/config.example.toml diff --git a/config/config.example.toml b/config/config.example.toml
index e173e06..a3c73be 100644 index 0b4d7b8..6d342bb 100644
--- a/config/config.example.toml --- a/config/config.example.toml
+++ b/config/config.example.toml +++ b/config/config.example.toml
@@ -15,6 +15,7 @@ @@ -16,6 +16,7 @@
# # secret key needs to be 16 characters long or more
# secret_key = "CHANGE_ME" # env variable: SERVER_SECRET_KEY # secret_key = "CHANGE_ME" # env variable: SERVER_SECRET_KEY
# verify_requests = false # verify_requests = false
# encrypt_query_params = false # env variable: SERVER_ENCRYPT_QUERY_PARAMS
+# max_dash_resolution = 1080 +# max_dash_resolution = 1080
# [cache] # [cache]
# enabled = true # enabled = true
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index 5ff4a2d..1ad0125 100644 index 273fe95..d1968fe 100644
--- a/src/lib/helpers/config.ts --- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts +++ b/src/lib/helpers/config.ts
@@ -9,6 +9,9 @@ const ConfigSchema = z.object({ @@ -12,6 +12,9 @@ const ConfigSchema = z.object({
Deno.env.get("SERVER_SECRET_KEY") || "", encrypt_query_params: z.boolean().default(
Deno.env.get("SERVER_ENCRYPT_QUERY_PARAMS") === "true" || false,
), ),
verify_requests: z.boolean().default(false),
+ max_dash_resolution: z.number().default( + max_dash_resolution: z.number().default(
+ Number(Deno.env.get("SERVER_MAX_DASH_RESOLUTION")), + Number(Deno.env.get("SERVER_MAX_DASH_RESOLUTION")),
+ ), + ),
@ -37,10 +37,10 @@ index 5ff4a2d..1ad0125 100644
cache: z.object({ cache: z.object({
enabled: z.boolean().default(true), enabled: z.boolean().default(true),
diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts
index 46756cd..68ae21d 100644 index 930eef1..96e8e2f 100644
--- a/src/routes/invidious_routes/dashManifest.ts --- a/src/routes/invidious_routes/dashManifest.ts
+++ b/src/routes/invidious_routes/dashManifest.ts +++ b/src/routes/invidious_routes/dashManifest.ts
@@ -61,7 +61,12 @@ dashManifest.get("/:videoId", async (c) => { @@ -62,7 +62,12 @@ dashManifest.get("/:videoId", async (c) => {
).includes("av01") ).includes("av01")
) { ) {
if (i.mime_type.includes("av01")) { if (i.mime_type.includes("av01")) {

View file

@ -1,26 +1,26 @@
From 9a8c0cf66ec6b2ad546c9448a907d8123ff1d65b Mon Sep 17 00:00:00 2001 From dc49b7941dc22c3c701250d90769df655257e300 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 19:06:04 -0300 Date: Mon, 24 Mar 2025 19:06:04 -0300
Subject: [PATCH 04/14] feat: add env variable to set verify_requests Subject: [PATCH 05/12] feat: add env variable to set verify_requests
--- ---
src/lib/helpers/config.ts | 4 +++- src/lib/helpers/config.ts | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-) 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index 1ad0125..05748f0 100644 index d1968fe..a5221c9 100644
--- a/src/lib/helpers/config.ts --- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts +++ b/src/lib/helpers/config.ts
@@ -8,7 +8,9 @@ const ConfigSchema = z.object({ @@ -8,7 +8,9 @@ const ConfigSchema = z.object({
secret_key: z.string().min(16).default( secret_key: z.string().length(16).default(
Deno.env.get("SERVER_SECRET_KEY") || "", Deno.env.get("SERVER_SECRET_KEY") || "",
), ),
- verify_requests: z.boolean().default(false), - verify_requests: z.boolean().default(false),
+ verify_requests: z.boolean().default( + verify_requests: z.boolean().default(
+ Deno.env.get("VERIFY_REQUESTS") === "true" || false, + Deno.env.get("VERIFY_REQUESTS") === "true" || false,
+ ), + ),
max_dash_resolution: z.number().default( encrypt_query_params: z.boolean().default(
Number(Deno.env.get("SERVER_MAX_DASH_RESOLUTION")), Deno.env.get("SERVER_ENCRYPT_QUERY_PARAMS") === "true" || false,
), ),
-- --
2.49.0 2.49.0

View file

@ -1,7 +1,7 @@
From 2efe34cfc218e20aedce6b03453dbebf71e4f782 Mon Sep 17 00:00:00 2001 From f940a206dedc8a70ceb507f4373c80a833ae709c Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 19:20:52 -0300 Date: Mon, 24 Mar 2025 19:20:52 -0300
Subject: [PATCH 05/14] feat: add support for multiple proxies Subject: [PATCH 06/12] feat: add support for multiple proxies
--- ---
src/lib/helpers/getFetchClient.ts | 17 ++++++++++++++++- src/lib/helpers/getFetchClient.ts | 17 ++++++++++++++++-

View file

@ -1,7 +1,7 @@
From ba7ed5b559806a1e3625a17b105c9429157f4e63 Mon Sep 17 00:00:00 2001 From 36bd0fa14574b05f15aa462cc485eb6b488a2ffc Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 20:34:33 -0300 Date: Mon, 24 Mar 2025 20:34:33 -0300
Subject: [PATCH 08/14] feat: add option to disable potoken generation check Subject: [PATCH 07/12] feat: add option to disable potoken generation check
--- ---
config/config.example.toml | 1 + config/config.example.toml | 1 +
@ -10,10 +10,10 @@ Subject: [PATCH 08/14] feat: add option to disable potoken generation check
3 files changed, 13 insertions(+), 1 deletion(-) 3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/config/config.example.toml b/config/config.example.toml diff --git a/config/config.example.toml b/config/config.example.toml
index a3c73be..4c04ee3 100644 index 6d342bb..969c768 100644
--- a/config/config.example.toml --- a/config/config.example.toml
+++ b/config/config.example.toml +++ b/config/config.example.toml
@@ -51,6 +51,7 @@ @@ -52,6 +52,7 @@
# [jobs.youtube_session] # [jobs.youtube_session]
# po_token_enabled = true # whether to generate PO tokens # po_token_enabled = true # whether to generate PO tokens
# frequency = "*/5 * * * *" # frequency of PO token refresh in cron format # frequency = "*/5 * * * *" # frequency of PO token refresh in cron format
@ -22,10 +22,10 @@ index a3c73be..4c04ee3 100644
# [youtube_session] # [youtube_session]
# oauth_enabled = false # oauth_enabled = false
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index 05748f0..a2f6be0 100644 index a5221c9..e6b1070 100644
--- a/src/lib/helpers/config.ts --- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts +++ b/src/lib/helpers/config.ts
@@ -39,6 +39,15 @@ const ConfigSchema = z.object({ @@ -42,6 +42,15 @@ const ConfigSchema = z.object({
youtube_session: z.object({ youtube_session: z.object({
po_token_enabled: z.boolean().default(true), po_token_enabled: z.boolean().default(true),
frequency: z.string().default("*/5 * * * *"), frequency: z.string().default("*/5 * * * *"),

View file

@ -1,25 +0,0 @@
From d805b8f591e9176f2b9990dd7c4184792d564efe Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 20:22:19 -0300
Subject: [PATCH 07/14] fix: cut off secret_key to 16 characters
---
src/lib/helpers/verifyRequest.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/helpers/verifyRequest.ts b/src/lib/helpers/verifyRequest.ts
index 0891839..d92d6d4 100644
--- a/src/lib/helpers/verifyRequest.ts
+++ b/src/lib/helpers/verifyRequest.ts
@@ -11,7 +11,7 @@ export const verifyRequest = (
try {
const decipher = new Ecb(
Aes,
- new TextEncoder().encode(config.server.secret_key),
+ new TextEncoder().encode(config.server.secret_key.substring(0, 16)),
Padding.PKCS7,
);
--
2.49.0

View file

@ -1,7 +1,7 @@
From 5f617136161bb6cf1571ee5aa361f6be5e69b33e Mon Sep 17 00:00:00 2001 From f475167ed0f1d60e4f8e50c1936ced761d0f72db Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Tue, 25 Mar 2025 00:04:47 -0300 Date: Tue, 25 Mar 2025 00:04:47 -0300
Subject: [PATCH 10/14] add proxy retries on innertube error Subject: [PATCH 08/12] add proxy retries on innertube error
--- ---
src/lib/helpers/config.ts | 1 + src/lib/helpers/config.ts | 1 +
@ -9,10 +9,10 @@ Subject: [PATCH 10/14] add proxy retries on innertube error
2 files changed, 23 insertions(+), 1 deletion(-) 2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index 83ce0fa..d539738 100644 index e6b1070..acbede2 100644
--- a/src/lib/helpers/config.ts --- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts +++ b/src/lib/helpers/config.ts
@@ -43,6 +43,7 @@ const ConfigSchema = z.object({ @@ -37,6 +37,7 @@ const ConfigSchema = z.object({
external_videoplayback_proxy: z.string().default( external_videoplayback_proxy: z.string().default(
Deno.env.get("EXTERNAL_VIDEOPLAYBACK_PROXY") || "", Deno.env.get("EXTERNAL_VIDEOPLAYBACK_PROXY") || "",
), ),

View file

@ -1,7 +1,7 @@
From 261eac162221700f4eb43f7633bdcfc0837a5ac8 Mon Sep 17 00:00:00 2001 From ae88bbd1aa4a42bad78d0241da22cc376a207e67 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Tue, 18 Mar 2025 16:38:23 -0300 Date: Tue, 18 Mar 2025 16:38:23 -0300
Subject: [PATCH 11/14] add support for prometheus metrics Subject: [PATCH 09/12] add support for prometheus metrics
fix deno lint and typo fix deno lint and typo
@ -37,12 +37,12 @@ fix: add missing metrics argument
create mode 100644 src/routes/metrics.ts create mode 100644 src/routes/metrics.ts
diff --git a/config/config.example.toml b/config/config.example.toml diff --git a/config/config.example.toml b/config/config.example.toml
index 4c04ee3..01c3f83 100644 index 969c768..a5800fb 100644
--- a/config/config.example.toml --- a/config/config.example.toml
+++ b/config/config.example.toml +++ b/config/config.example.toml
@@ -16,6 +16,7 @@ @@ -17,6 +17,7 @@
# secret_key = "CHANGE_ME" # env variable: SERVER_SECRET_KEY
# verify_requests = false # verify_requests = false
# encrypt_query_params = false # env variable: SERVER_ENCRYPT_QUERY_PARAMS
# max_dash_resolution = 1080 # max_dash_resolution = 1080
+# enable_metrics = false # env variable: ENABLE_METRICS +# enable_metrics = false # env variable: ENABLE_METRICS
@ -2153,13 +2153,13 @@ index 9a772c7..6a3432d 100644
} }
} }
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index d539738..646132f 100644 index acbede2..50f3f8b 100644
--- a/src/lib/helpers/config.ts --- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts +++ b/src/lib/helpers/config.ts
@@ -23,6 +23,13 @@ const ConfigSchema = z.object({ @@ -17,6 +17,13 @@ const ConfigSchema = z.object({
? false max_dash_resolution: z.number().default(
: true, Number(Deno.env.get("SERVER_MAX_DASH_RESOLUTION")),
), ),
+ enable_metrics: z.boolean().default( + enable_metrics: z.boolean().default(
+ Deno.env.get("ENABLE_METRICS") === "true" + Deno.env.get("ENABLE_METRICS") === "true"
+ ? true + ? true
@ -2170,7 +2170,7 @@ index d539738..646132f 100644
}).strict().default({}), }).strict().default({}),
cache: z.object({ cache: z.object({
enabled: z.boolean().default(true), enabled: z.boolean().default(true),
@@ -43,7 +50,9 @@ const ConfigSchema = z.object({ @@ -37,7 +44,9 @@ const ConfigSchema = z.object({
external_videoplayback_proxy: z.string().default( external_videoplayback_proxy: z.string().default(
Deno.env.get("EXTERNAL_VIDEOPLAYBACK_PROXY") || "", Deno.env.get("EXTERNAL_VIDEOPLAYBACK_PROXY") || "",
), ),
@ -2494,7 +2494,7 @@ index 4f42d28..1e9b7a2 100644
+ metrics: Metrics | undefined; + metrics: Metrics | undefined;
}; };
diff --git a/src/main.ts b/src/main.ts diff --git a/src/main.ts b/src/main.ts
index a792fee..c2c265e 100644 index 2968a3e..851cd71 100644
--- a/src/main.ts --- a/src/main.ts
+++ b/src/main.ts +++ b/src/main.ts
@@ -9,6 +9,7 @@ import type { HonoVariables } from "./lib/types/HonoVariables.ts"; @@ -9,6 +9,7 @@ import type { HonoVariables } from "./lib/types/HonoVariables.ts";
@ -2513,15 +2513,15 @@ index a792fee..c2c265e 100644
let tokenMinter: BG.WebPoMinter; let tokenMinter: BG.WebPoMinter;
let innertubeClient: Innertube; let innertubeClient: Innertube;
@@ -72,6 +74,7 @@ if (!innertubeClientOauthEnabled) { @@ -66,6 +68,7 @@ if (!innertubeClientOauthEnabled) {
innertubeClient, innertubeClient,
config, config,
innertubeClientCache as UniversalCache, innertubeClientCache,
+ metrics, + metrics,
), ),
{ minTimeout: 1_000, maxTimeout: 60_000, multiplier: 5, jitter: 0 }, { minTimeout: 1_000, maxTimeout: 60_000, multiplier: 5, jitter: 0 },
)); ));
@@ -82,11 +85,17 @@ if (!innertubeClientOauthEnabled) { @@ -76,11 +79,17 @@ if (!innertubeClientOauthEnabled) {
{ backoffSchedule: [5_000, 15_000, 60_000, 180_000] }, { backoffSchedule: [5_000, 15_000, 60_000, 180_000] },
async () => { async () => {
if (innertubeClientJobPoTokenEnabled) { if (innertubeClientJobPoTokenEnabled) {
@ -2544,7 +2544,7 @@ index a792fee..c2c265e 100644
} else { } else {
innertubeClient = await Innertube.create({ innertubeClient = await Innertube.create({
enable_session_cache: false, enable_session_cache: false,
@@ -124,6 +133,7 @@ app.use("*", async (c, next) => { @@ -118,6 +127,7 @@ app.use("*", async (c, next) => {
c.set("innertubeClient", innertubeClient); c.set("innertubeClient", innertubeClient);
c.set("tokenMinter", tokenMinter); c.set("tokenMinter", tokenMinter);
c.set("config", config); c.set("config", config);
@ -2593,7 +2593,7 @@ index 1eaeb14..f900298 100644
const videoInfo = youtubeVideoInfo( const videoInfo = youtubeVideoInfo(
diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts
index a4c0950..414b4cf 100644 index 96e8e2f..34e0b6e 100644
--- a/src/routes/invidious_routes/dashManifest.ts --- a/src/routes/invidious_routes/dashManifest.ts
+++ b/src/routes/invidious_routes/dashManifest.ts +++ b/src/routes/invidious_routes/dashManifest.ts
@@ -17,6 +17,7 @@ dashManifest.get("/:videoId", async (c) => { @@ -17,6 +17,7 @@ dashManifest.get("/:videoId", async (c) => {
@ -2613,7 +2613,7 @@ index a4c0950..414b4cf 100644
const videoInfo = youtubeVideoInfo( const videoInfo = youtubeVideoInfo(
innertubeClient, innertubeClient,
diff --git a/src/routes/invidious_routes/latestVersion.ts b/src/routes/invidious_routes/latestVersion.ts diff --git a/src/routes/invidious_routes/latestVersion.ts b/src/routes/invidious_routes/latestVersion.ts
index f1a7605..dbf57c2 100644 index 07b070a..74dd090 100644
--- a/src/routes/invidious_routes/latestVersion.ts --- a/src/routes/invidious_routes/latestVersion.ts
+++ b/src/routes/invidious_routes/latestVersion.ts +++ b/src/routes/invidious_routes/latestVersion.ts
@@ -21,6 +21,7 @@ latestVersion.get("/", async (c) => { @@ -21,6 +21,7 @@ latestVersion.get("/", async (c) => {

View file

@ -1,172 +0,0 @@
From 4e14b2c9914d9f10e70394d25c0bf225acebbabe Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 21:38:33 -0300
Subject: [PATCH 09/14] feat: add support for encrypted query parameters
---
src/lib/helpers/config.ts | 9 ++++
src/lib/helpers/encrypter.ts | 56 ++++++++++++++++++++
src/routes/invidious_routes/dashManifest.ts | 18 +++++--
src/routes/invidious_routes/latestVersion.ts | 14 ++++-
4 files changed, 91 insertions(+), 6 deletions(-)
create mode 100644 src/lib/helpers/encrypter.ts
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index a2f6be0..83ce0fa 100644
--- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts
@@ -14,6 +14,15 @@ const ConfigSchema = z.object({
max_dash_resolution: z.number().default(
Number(Deno.env.get("SERVER_MAX_DASH_RESOLUTION")),
),
+ encrypt_query_params: z
+ .boolean()
+ .default(
+ Deno.env.get("ENCRYPT_QUERY_PARAMS") === "true"
+ ? true
+ : Deno.env.get("ENCRYPT_QUERY_PARAMS") === "false"
+ ? false
+ : true,
+ ),
}).strict().default({}),
cache: z.object({
enabled: z.boolean().default(true),
diff --git a/src/lib/helpers/encrypter.ts b/src/lib/helpers/encrypter.ts
new file mode 100644
index 0000000..4b45590
--- /dev/null
+++ b/src/lib/helpers/encrypter.ts
@@ -0,0 +1,56 @@
+import { decodeBase64, encodeBase64 } from "@std/encoding/base64";
+import { Aes } from "crypto/aes.ts";
+import { Ecb, Padding } from "crypto/block-modes.ts";
+import { Config } from "./config.ts";
+
+export const encryptQuery = (
+ queryParams: string,
+ config: Config,
+): string => {
+ try {
+ const cipher = new Ecb(
+ Aes,
+ new TextEncoder().encode(config.server.secret_key.substring(0, 16)),
+ Padding.PKCS7,
+ );
+
+ const encodedData = new TextEncoder().encode(
+ queryParams,
+ );
+
+ const encryptedData = cipher.encrypt(encodedData);
+
+ return encodeBase64(encryptedData).replace(/\+/g, "-").replace(
+ /\//g,
+ "_",
+ );
+ } catch (_) {
+ return "";
+ }
+};
+
+export const decryptQuery = (
+ queryParams: string,
+ config: Config,
+): string => {
+ try {
+ const decipher = new Ecb(
+ Aes,
+ new TextEncoder().encode(config.server.secret_key.substring(0, 16)),
+ Padding.PKCS7,
+ );
+
+ const decryptedData = new TextDecoder().decode(
+ decipher.decrypt(
+ decodeBase64(
+ queryParams.replace(/-/g, "+").replace(/_/g, "/"),
+ ),
+ ),
+ );
+
+ console.log(decryptedData);
+ return decryptedData;
+ } catch (_) {
+ return "";
+ }
+};
diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts
index 68ae21d..a4c0950 100644
--- a/src/routes/invidious_routes/dashManifest.ts
+++ b/src/routes/invidious_routes/dashManifest.ts
@@ -6,6 +6,7 @@ import {
} from "../../lib/helpers/youtubePlayerHandling.ts";
import { verifyRequest } from "../../lib/helpers/verifyRequest.ts";
import { HTTPException } from "hono/http-exception";
+import { encryptQuery } from "../../lib/helpers/encrypter.ts";
const dashManifest = new Hono();
@@ -88,14 +89,23 @@ dashManifest.get("/:videoId", async (c) => {
videoInfo.page[0].video_details?.is_post_live_dvr,
(url: URL) => {
let dashUrl = url;
+ let queryParams = dashUrl.search.substring(1) + "&host=" +
+ dashUrl.host;
+
if (local) {
- // Can't create URL type without host part
- dashUrl = config.networking.external_videoplayback_proxy +
- (dashUrl.pathname + dashUrl.search + "&host=" +
- dashUrl.host) as unknown as URL;
if (config.networking.ump) {
dashUrl = dashUrl + "&ump=1" as unknown as URL;
}
+ if (config.server.encrypt_query_params) {
+ queryParams = "enc=yes&data=" + encryptQuery(
+ queryParams,
+ config,
+ );
+ }
+ // Can't create URL type without host part
+ dashUrl = config.networking.external_videoplayback_proxy +
+ (dashUrl.pathname + "?" +
+ queryParams) 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 a8ead67..f1a7605 100644
--- a/src/routes/invidious_routes/latestVersion.ts
+++ b/src/routes/invidious_routes/latestVersion.ts
@@ -5,6 +5,7 @@ import {
youtubeVideoInfo,
} from "../../lib/helpers/youtubePlayerHandling.ts";
import { verifyRequest } from "../../lib/helpers/verifyRequest.ts";
+import { encryptQuery } from "../../lib/helpers/encrypter.ts";
const latestVersion = new Hono();
@@ -63,10 +64,19 @@ latestVersion.get("/", async (c) => {
const itagUrl = selectedItagFormat[0].url as string;
const itagUrlParsed = new URL(itagUrl);
let urlToRedirect = itagUrlParsed.toString();
+ let queryParams = itagUrlParsed.search.substring(1) + "&host=" +
+ itagUrlParsed.host;
+
if (local) {
+ if (config.server.encrypt_query_params) {
+ queryParams = "enc=yes&data=" + encryptQuery(
+ queryParams,
+ config,
+ );
+ }
+
urlToRedirect = config.networking.external_videoplayback_proxy +
- itagUrlParsed.pathname + itagUrlParsed.search +
- "&host=" + itagUrlParsed.host;
+ itagUrlParsed.pathname + "?" + queryParams;
}
if (title) urlToRedirect += `&title=${encodeURIComponent(title)}`;
--
2.49.0

View file

@ -1,7 +1,7 @@
From 75d88c65065d0d4e3af4651332c9d5fc4ad5c3cf Mon Sep 17 00:00:00 2001 From 99a492d9bafd6f5bd1482df08441ebb703b45a59 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Tue, 25 Mar 2025 00:07:28 -0300 Date: Tue, 25 Mar 2025 00:07:28 -0300
Subject: [PATCH 12/14] add metrics for proxy retries Subject: [PATCH 10/12] add metrics for proxy retries
--- ---
src/lib/helpers/metrics.ts | 5 +++++ src/lib/helpers/metrics.ts | 5 +++++

View file

@ -1,18 +1,18 @@
From 695e7338dd56fb7e28f32b4e5fd6f1b81701b992 Mon Sep 17 00:00:00 2001 From d54369cd1b97d5beeaf0d867d2c24a36a2a0445c Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Tue, 25 Mar 2025 00:24:07 -0300 Date: Tue, 25 Mar 2025 00:24:07 -0300
Subject: [PATCH 13/14] fix: fix tokio overflow on compile Subject: [PATCH 11/12] fix: fix tokio overflow on compile
--- ---
Dockerfile | 2 ++ Dockerfile | 2 ++
1 file changed, 2 insertions(+) 1 file changed, 2 insertions(+)
diff --git a/Dockerfile b/Dockerfile diff --git a/Dockerfile b/Dockerfile
index a6dc150..bdc43f5 100644 index 0f9f933..99fce38 100644
--- a/Dockerfile --- a/Dockerfile
+++ b/Dockerfile +++ b/Dockerfile
@@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
FROM denoland/deno:debian-2.2.4 AS builder FROM denoland/deno:debian-2.2.5 AS builder
+ENV RUST_MIN_STACK=9999999999 +ENV RUST_MIN_STACK=9999999999
+ +

View file

@ -1,17 +1,17 @@
From 0855ac4ec1c614f25dccbdfb4fc97bc0789d5ad7 Mon Sep 17 00:00:00 2001 From db6ff1b23bc50dba40611277e26e797da12b9685 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net> From: Fijxu <fijxu@nadeko.net>
Date: Wed, 26 Mar 2025 12:24:49 -0300 Date: Wed, 26 Mar 2025 12:24:49 -0300
Subject: [PATCH 14/14] Add environment variable for youtube_session.frequency Subject: [PATCH 12/12] Add environment variable for youtube_session.frequency
--- ---
src/lib/helpers/config.ts | 4 +++- src/lib/helpers/config.ts | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-) 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index 646132f..16e4fbb 100644 index 50f3f8b..8cf34fd 100644
--- a/src/lib/helpers/config.ts --- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts +++ b/src/lib/helpers/config.ts
@@ -57,7 +57,9 @@ const ConfigSchema = z.object({ @@ -51,7 +51,9 @@ const ConfigSchema = z.object({
jobs: z.object({ jobs: z.object({
youtube_session: z.object({ youtube_session: z.object({
po_token_enabled: z.boolean().default(true), po_token_enabled: z.boolean().default(true),