From 0a811861e2cf1cd0a667bf6083fcef47ca0e2ab6 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Fri, 20 Dec 2024 20:33:42 -0300 Subject: [PATCH] support for video_cache on disk --- src/lib/helpers/youtubePlayerHandling.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/helpers/youtubePlayerHandling.ts b/src/lib/helpers/youtubePlayerHandling.ts index 7dd6fbe..ca5aadc 100644 --- a/src/lib/helpers/youtubePlayerHandling.ts +++ b/src/lib/helpers/youtubePlayerHandling.ts @@ -16,7 +16,15 @@ if (Deno.env.get("YT_PLAYER_REQ_LOCATION")) { } const { youtubePlayerReq } = await import(youtubePlayerReqLocation); -const kv = await Deno.openKv(); +const videoCachePath = Deno.env.get("VIDEO_CACHE_PATH") as string || "/var/tmp/youtubei.js/video_cache" + +let kv : Deno.Kv +if ((Deno.env.get("VIDEO_CACHE_ON_DISK") as string).toLowerCase() == "true") { + console.log("[INFO] Storing video cache on disk") + kv = await Deno.openKv(videoCachePath); +} else { + kv = await Deno.openKv(); +} export const youtubePlayerParsing = async ( innertubeClient: Innertube,