From 551cf0075bbfda175d25d510a53e43178e0d7e81 Mon Sep 17 00:00:00 2001 From: Emilien Devos <4016501+unixfox@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:29:14 +0200 Subject: [PATCH] allow to turn on or off po_token --- config/default.toml | 4 +++- src/main.ts | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config/default.toml b/config/default.toml index 671928f..e12f3dd 100644 --- a/config/default.toml +++ b/config/default.toml @@ -11,4 +11,6 @@ enabled = true #proxy = "" [jobs] -po_token_cron = "*/5 * * * *" \ No newline at end of file +[po_token] +enabled = true +frequency = "*/5 * * * *" \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index c10494c..3c7698e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,11 +8,16 @@ const app = new Hono(); const konfigStore = await konfigLoader(); -let innertubeClient = await Innertube.create({ retrieve_player: false }); +let innertubeClient: Innertube; -innertubeClient = await poTokenGenerate(innertubeClient, konfigStore); +if (konfigStore.get("jobs.po_token.enabled") as boolean) { + innertubeClient = await Innertube.create({ retrieve_player: false }); + innertubeClient = await poTokenGenerate(innertubeClient, konfigStore); +} else { + await Innertube.create(); +} -Deno.cron("regenerate poToken", konfigStore.get("jobs.po_token_cron") as string, async () => { +Deno.cron("regenerate poToken", konfigStore.get("jobs.po_token.frequency") as string, async () => { innertubeClient = await poTokenGenerate(innertubeClient, konfigStore); });