From 7ed48ad2afd076636fb542eb249a699ca99e8c90 Mon Sep 17 00:00:00 2001 From: Emilien <4016501+unixfox@users.noreply.github.com> Date: Mon, 18 Nov 2024 00:31:11 +0100 Subject: [PATCH] allow to dynamically load external files for youtubeplayerreq + fetchclient --- src/lib/helpers/youtubePlayerHandling.ts | 2 +- src/lib/jobs/potoken.ts | 2 +- src/main.ts | 2 +- src/routes/videoPlaybackProxy.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/helpers/youtubePlayerHandling.ts b/src/lib/helpers/youtubePlayerHandling.ts index 1daaea5..8a5849e 100644 --- a/src/lib/helpers/youtubePlayerHandling.ts +++ b/src/lib/helpers/youtubePlayerHandling.ts @@ -1,7 +1,7 @@ import { Innertube, YT, ApiResponse } from "youtubei.js"; import { generateRandomString } from "youtubei.js/Utils"; import { compress, decompress } from "https://deno.land/x/brotli@0.1.7/mod.ts"; -import { youtubePlayerReq } from "youtubePlayerReq"; +const { youtubePlayerReq } = await import(Deno.env.get("YT_PLAYER_REQ_LOCATION") || "./youtubePlayerReq.ts"); import { Store } from "@willsoto/node-konfig-core"; const kv = await Deno.openKv(); diff --git a/src/lib/jobs/potoken.ts b/src/lib/jobs/potoken.ts index 6bd6916..ff6c369 100644 --- a/src/lib/jobs/potoken.ts +++ b/src/lib/jobs/potoken.ts @@ -3,7 +3,7 @@ import type { BgConfig } from "bgutils"; import { JSDOM } from "jsdom"; import { Innertube, UniversalCache } from "youtubei.js"; import { Store } from "@willsoto/node-konfig-core"; -import { getFetchClient } from "../helpers/getFetchClient.ts"; +const { getFetchClient } = await import(Deno.env.get("GET_FETCH_CLIENT_LOCATION") || "../helpers/getFetchClient.ts"); // Adapted from https://github.com/LuanRT/BgUtils/blob/main/examples/node/index.ts export const poTokenGenerate = async ( diff --git a/src/main.ts b/src/main.ts index cd6ec74..2d43373 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,7 @@ import { routes } from "./routes/index.ts"; import { Innertube, UniversalCache } from "youtubei.js"; import { poTokenGenerate } from "./lib/jobs/potoken.ts"; import { konfigLoader } from "./lib/helpers/konfigLoader.ts"; -import { getFetchClient } from "./lib/helpers/getFetchClient.ts"; +const { getFetchClient } = await import(Deno.env.get("GET_FETCH_CLIENT_LOCATION") || "./lib/helpers/getFetchClient.ts"); const app = new Hono(); const konfigStore = await konfigLoader(); diff --git a/src/routes/videoPlaybackProxy.ts b/src/routes/videoPlaybackProxy.ts index 5fcfe4e..ead43d0 100644 --- a/src/routes/videoPlaybackProxy.ts +++ b/src/routes/videoPlaybackProxy.ts @@ -1,6 +1,6 @@ import { Hono } from "hono"; import { Store } from "@willsoto/node-konfig-core"; -import { getFetchClient } from "../lib/helpers/getFetchClient.ts"; +const { getFetchClient } = await import(Deno.env.get("GET_FETCH_CLIENT_LOCATION") || "../lib/helpers/getFetchClient.ts"); import { HTTPException } from "hono/http-exception"; const videoPlaybackProxy = new Hono();