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>
|
||||
>;
|
||||
|
||||
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, {
|
||||
res: new Response("No check ID."),
|
||||
});
|
||||
} else if (konfigStore.get("server.verify_requests") && check) {
|
||||
} else if (verifyRequests && check) {
|
||||
if (verifyRequest(check, videoId, konfigStore) === false) {
|
||||
throw new HTTPException(400, {
|
||||
res: new Response("ID incorrect."),
|
||||
|
@ -96,8 +100,11 @@ dashManifest.get("/:videoId", async (c) => {
|
|||
let dashUrl = url;
|
||||
if (local) {
|
||||
// Can't create URL type without host part
|
||||
dashUrl = (konfigStore.get("networking.external_videoplayback_proxy") as string ?? "") + (dashUrl.pathname + dashUrl.search + "&host=" +
|
||||
dashUrl.host) as unknown as URL;
|
||||
dashUrl = (konfigStore.get(
|
||||
"networking.external_videoplayback_proxy",
|
||||
) as string ?? "") +
|
||||
(dashUrl.pathname + dashUrl.search + "&host=" +
|
||||
dashUrl.host) as unknown as URL;
|
||||
if (konfigStore.get("networking.ump") as boolean) {
|
||||
dashUrl = dashUrl + "&ump=1" as unknown as URL;
|
||||
}
|
||||
|
|
|
@ -26,12 +26,14 @@ latestVersion.get("/", async (c) => {
|
|||
const konfigStore = await c.get("konfigStore") as Store<
|
||||
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, {
|
||||
res: new Response("No check ID."),
|
||||
});
|
||||
} else if (konfigStore.get("server.verify_requests") && check) {
|
||||
} else if (verifyRequests && check) {
|
||||
if (verifyRequest(check, id, konfigStore) === false) {
|
||||
throw new HTTPException(400, {
|
||||
res: new Response("ID incorrect."),
|
||||
|
@ -69,7 +71,9 @@ latestVersion.get("/", async (c) => {
|
|||
const itagUrlParsed = new URL(itagUrl);
|
||||
let urlToRedirect = itagUrlParsed.toString();
|
||||
if (local) {
|
||||
urlToRedirect = (konfigStore.get("networking.external_videoplayback_proxy") as string ?? "") +
|
||||
urlToRedirect = (konfigStore.get(
|
||||
"networking.external_videoplayback_proxy",
|
||||
) as string ?? "") +
|
||||
itagUrlParsed.pathname + itagUrlParsed.search +
|
||||
"&host=" + itagUrlParsed.host;
|
||||
}
|
||||
|
|
Reference in a new issue