All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m14s
59 lines
2.3 KiB
Diff
59 lines
2.3 KiB
Diff
From e89236d910bb112204448765055a985dc2a589d5 Mon Sep 17 00:00:00 2001
|
|
From: Fijxu <fijxu@nadeko.net>
|
|
Date: Mon, 24 Mar 2025 19:02:01 -0300
|
|
Subject: [PATCH 04/12] 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 0b4d7b8..6d342bb 100644
|
|
--- a/config/config.example.toml
|
|
+++ b/config/config.example.toml
|
|
@@ -16,6 +16,7 @@
|
|
# secret_key = "CHANGE_ME" # env variable: SERVER_SECRET_KEY
|
|
# verify_requests = false
|
|
# encrypt_query_params = false # env variable: SERVER_ENCRYPT_QUERY_PARAMS
|
|
+# max_dash_resolution = 1080
|
|
|
|
# [cache]
|
|
# enabled = true
|
|
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
|
|
index 273fe95..d1968fe 100644
|
|
--- a/src/lib/helpers/config.ts
|
|
+++ b/src/lib/helpers/config.ts
|
|
@@ -12,6 +12,9 @@ const ConfigSchema = z.object({
|
|
encrypt_query_params: z.boolean().default(
|
|
Deno.env.get("SERVER_ENCRYPT_QUERY_PARAMS") === "true" || 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 930eef1..96e8e2f 100644
|
|
--- a/src/routes/invidious_routes/dashManifest.ts
|
|
+++ b/src/routes/invidious_routes/dashManifest.ts
|
|
@@ -62,7 +62,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
|
|
|