add resolution limit to save bandwidth
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m8s

add environment variable for the resolution limit
This commit is contained in:
Fijxu 2024-12-18 19:38:54 -03:00
parent 309015454b
commit 12c965ceaf
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
2 changed files with 9 additions and 1 deletions

View file

@ -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

View file

@ -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."),
@ -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;
}