feat: add env variable for verify_requests
This commit is contained in:
parent
6c6345fe03
commit
55df6e6692
2 changed files with 19 additions and 8 deletions
|
@ -22,13 +22,17 @@ 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;
|
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) {
|
const verifyRequests = Deno.env.get("VERIFY_REQUESTS") ||
|
||||||
|
konfigStore.get("server.verify_requests");
|
||||||
|
|
||||||
|
if (verifyRequests && check == undefined) {
|
||||||
throw new HTTPException(400, {
|
throw new HTTPException(400, {
|
||||||
res: new Response("No check ID."),
|
res: new Response("No check ID."),
|
||||||
});
|
});
|
||||||
} else if (konfigStore.get("server.verify_requests") && check) {
|
} else if (verifyRequests && check) {
|
||||||
if (verifyRequest(check, videoId, konfigStore) === false) {
|
if (verifyRequest(check, videoId, konfigStore) === false) {
|
||||||
throw new HTTPException(400, {
|
throw new HTTPException(400, {
|
||||||
res: new Response("ID incorrect."),
|
res: new Response("ID incorrect."),
|
||||||
|
@ -96,8 +100,11 @@ dashManifest.get("/:videoId", async (c) => {
|
||||||
let dashUrl = url;
|
let dashUrl = url;
|
||||||
if (local) {
|
if (local) {
|
||||||
// Can't create URL type without host part
|
// Can't create URL type without host part
|
||||||
dashUrl = (konfigStore.get("networking.external_videoplayback_proxy") as string ?? "") + (dashUrl.pathname + dashUrl.search + "&host=" +
|
dashUrl = (konfigStore.get(
|
||||||
dashUrl.host) as unknown as URL;
|
"networking.external_videoplayback_proxy",
|
||||||
|
) as string ?? "") +
|
||||||
|
(dashUrl.pathname + dashUrl.search + "&host=" +
|
||||||
|
dashUrl.host) as unknown as URL;
|
||||||
if (konfigStore.get("networking.ump") as boolean) {
|
if (konfigStore.get("networking.ump") as boolean) {
|
||||||
dashUrl = dashUrl + "&ump=1" as unknown as URL;
|
dashUrl = dashUrl + "&ump=1" as unknown as URL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,14 @@ latestVersion.get("/", async (c) => {
|
||||||
const konfigStore = await c.get("konfigStore") as Store<
|
const konfigStore = await c.get("konfigStore") as Store<
|
||||||
Record<string, unknown>
|
Record<string, unknown>
|
||||||
>;
|
>;
|
||||||
|
const verifyRequests = Deno.env.get("VERIFY_REQUESTS") ||
|
||||||
|
konfigStore.get("server.verify_requests");
|
||||||
|
|
||||||
if (konfigStore.get("server.verify_requests") && check == undefined) {
|
if (verifyRequests && check == undefined) {
|
||||||
throw new HTTPException(400, {
|
throw new HTTPException(400, {
|
||||||
res: new Response("No check ID."),
|
res: new Response("No check ID."),
|
||||||
});
|
});
|
||||||
} else if (konfigStore.get("server.verify_requests") && check) {
|
} else if (verifyRequests && check) {
|
||||||
if (verifyRequest(check, id, konfigStore) === false) {
|
if (verifyRequest(check, id, konfigStore) === false) {
|
||||||
throw new HTTPException(400, {
|
throw new HTTPException(400, {
|
||||||
res: new Response("ID incorrect."),
|
res: new Response("ID incorrect."),
|
||||||
|
@ -69,7 +71,9 @@ latestVersion.get("/", async (c) => {
|
||||||
const itagUrlParsed = new URL(itagUrl);
|
const itagUrlParsed = new URL(itagUrl);
|
||||||
let urlToRedirect = itagUrlParsed.toString();
|
let urlToRedirect = itagUrlParsed.toString();
|
||||||
if (local) {
|
if (local) {
|
||||||
urlToRedirect = (konfigStore.get("networking.external_videoplayback_proxy") as string ?? "") +
|
urlToRedirect = (konfigStore.get(
|
||||||
|
"networking.external_videoplayback_proxy",
|
||||||
|
) as string ?? "") +
|
||||||
itagUrlParsed.pathname + itagUrlParsed.search +
|
itagUrlParsed.pathname + itagUrlParsed.search +
|
||||||
"&host=" + itagUrlParsed.host;
|
"&host=" + itagUrlParsed.host;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue