add resolution limit to save bandwidth
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m8s
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:
parent
309015454b
commit
12c965ceaf
2 changed files with 9 additions and 1 deletions
|
@ -5,6 +5,7 @@ host = "127.0.0.1"
|
||||||
secret_key = "CHANGE_ME"
|
secret_key = "CHANGE_ME"
|
||||||
base_url = "http://localhost:8282"
|
base_url = "http://localhost:8282"
|
||||||
verify_requests = false
|
verify_requests = false
|
||||||
|
# max_dash_resolution = 1080
|
||||||
|
|
||||||
[cache]
|
[cache]
|
||||||
enabled = true
|
enabled = true
|
||||||
|
|
|
@ -24,6 +24,8 @@ dashManifest.get("/:videoId", async (c) => {
|
||||||
Record<string, unknown>
|
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) {
|
if (konfigStore.get("server.verify_requests") && check == undefined) {
|
||||||
throw new HTTPException(400, {
|
throw new HTTPException(400, {
|
||||||
res: new Response("No check ID."),
|
res: new Response("No check ID."),
|
||||||
|
@ -67,7 +69,12 @@ dashManifest.get("/:videoId", async (c) => {
|
||||||
).includes("av01")
|
).includes("av01")
|
||||||
) {
|
) {
|
||||||
if (i.mime_type.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 {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue