Skip to content

Commit

Permalink
add resolution limit to save bandwidth
Browse files Browse the repository at this point in the history
add environment variable for the resolution limit
  • Loading branch information
Fijxu committed Dec 29, 2024
1 parent 8084936 commit d6c64b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ host = "127.0.0.1"
secret_key = "CHANGE_ME"
base_url = "http://localhost:8282"
verify_requests = false
# max_dash_resolution = 1080

[cache]
enabled = true
Expand Down
9 changes: 8 additions & 1 deletion src/routes/invidious_routes/dashManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ dashManifest.get("/:videoId", async (c) => {
Record<string, unknown>
>;

const maxDashResolution = Deno.env.get("SERVER_MAX_DASH_RESOLUTION") || konfigStore.get("server.max_dash_resolution") as number;

if (konfigStore.get("server.verify_requests") && check == undefined) {
throw new HTTPException(400, {
res: new Response("No check ID."),
Expand Down Expand Up @@ -67,7 +69,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 > maxDashResolution) {
return false;
} else {
return true;
}
} else {
return false;
}
Expand Down

0 comments on commit d6c64b0

Please sign in to comment.