All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m4s
59 lines
2.2 KiB
Diff
59 lines
2.2 KiB
Diff
From bcc993ffefc44e1d3b2678cb2ffe8bbd4f1eee62 Mon Sep 17 00:00:00 2001
|
|
From: Fijxu <fijxu@nadeko.net>
|
|
Date: Mon, 24 Mar 2025 19:02:01 -0300
|
|
Subject: [PATCH 3/7] feat: add resolution limit on DASH streams to save
|
|
bandwidth
|
|
|
|
---
|
|
config/config.example.toml | 1 +
|
|
src/lib/helpers/config.ts | 3 +++
|
|
src/routes/invidious_routes/dashManifest.ts | 7 ++++++-
|
|
3 files changed, 10 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/config/config.example.toml b/config/config.example.toml
|
|
index e173e06..a3c73be 100644
|
|
--- a/config/config.example.toml
|
|
+++ b/config/config.example.toml
|
|
@@ -15,6 +15,7 @@
|
|
# # secret key needs to be 16 characters long or more
|
|
# secret_key = "CHANGE_ME" # env variable: SERVER_SECRET_KEY
|
|
# verify_requests = false
|
|
+# max_dash_resolution = 1080
|
|
|
|
# [cache]
|
|
# enabled = true
|
|
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
|
|
index 5ff4a2d..1ad0125 100644
|
|
--- a/src/lib/helpers/config.ts
|
|
+++ b/src/lib/helpers/config.ts
|
|
@@ -9,6 +9,9 @@ const ConfigSchema = z.object({
|
|
Deno.env.get("SERVER_SECRET_KEY") || "",
|
|
),
|
|
verify_requests: z.boolean().default(false),
|
|
+ max_dash_resolution: z.number().default(
|
|
+ Number(Deno.env.get("SERVER_MAX_DASH_RESOLUTION")),
|
|
+ ),
|
|
}).strict().default({}),
|
|
cache: z.object({
|
|
enabled: z.boolean().default(true),
|
|
diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts
|
|
index 46756cd..68ae21d 100644
|
|
--- a/src/routes/invidious_routes/dashManifest.ts
|
|
+++ b/src/routes/invidious_routes/dashManifest.ts
|
|
@@ -61,7 +61,12 @@ dashManifest.get("/:videoId", async (c) => {
|
|
).includes("av01")
|
|
) {
|
|
if (i.mime_type.includes("av01")) {
|
|
- return true;
|
|
+ // @ts-ignore 'i.height' is possibly 'undefined'.
|
|
+ if (i.height > config.server.max_dash_resolution) {
|
|
+ return false;
|
|
+ } else {
|
|
+ return true;
|
|
+ }
|
|
} else {
|
|
return false;
|
|
}
|
|
--
|
|
2.49.0
|
|
|