mirror of
https://git.nerdvpn.de/NerdVPN.de/invidious
synced 2026-02-14 22:51:42 +01:00
55 lines
2.2 KiB
Diff
55 lines
2.2 KiB
Diff
From 04eb4c82d81a4ff183d2e94eff474136841ff1a1 Mon Sep 17 00:00:00 2001
|
|
From: Fijxu <fijxu@nadeko.net>
|
|
Date: Mon, 24 Mar 2025 19:02:01 -0300
|
|
Subject: [PATCH 01/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 | 3 ++-
|
|
3 files changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/config/config.example.toml b/config/config.example.toml
|
|
index 2a49d0f..d711ca0 100644
|
|
--- a/config/config.example.toml
|
|
+++ b/config/config.example.toml
|
|
@@ -17,6 +17,7 @@
|
|
# verify_requests = false # env variable: SERVER_VERIFY_REQUESTS
|
|
# encrypt_query_params = false # env variable: SERVER_ENCRYPT_QUERY_PARAMS
|
|
# enable_metrics = false # env variable: SERVER_ENABLE_METRICS
|
|
+# max_dash_resolution = 1080
|
|
|
|
# [cache]
|
|
# enabled = true # env variable: CACHE_ENABLED
|
|
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
|
|
index 6ec7112..793265e 100644
|
|
--- a/src/lib/helpers/config.ts
|
|
+++ b/src/lib/helpers/config.ts
|
|
@@ -17,6 +17,9 @@ export const ConfigSchema = z.object({
|
|
enable_metrics: z.boolean().default(
|
|
Deno.env.get("SERVER_ENABLE_METRICS") === "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(
|
|
diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts
|
|
index 059b4ed..2ebb783 100644
|
|
--- a/src/routes/invidious_routes/dashManifest.ts
|
|
+++ b/src/routes/invidious_routes/dashManifest.ts
|
|
@@ -55,7 +55,8 @@ dashManifest.get("/:videoId", async (c) => {
|
|
videoInfo.streaming_data.adaptive_formats = videoInfo
|
|
.streaming_data.adaptive_formats
|
|
.filter((i) =>
|
|
- i.has_video === false || i.mime_type.includes("mp4")
|
|
+ //@ts-ignore: 'i.height' is possibly 'undefined'.
|
|
+ i.has_video === false || (i.mime_type.includes("mp4") && (i.height <= config.server.max_dash_resolution))
|
|
);
|
|
|
|
const player_response = videoInfo.page[0];
|
|
--
|
|
2.49.0
|