feat: add option to disable potoken generation check
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m5s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m5s
This commit is contained in:
parent
f878efd1d0
commit
cae1dad04e
9 changed files with 147 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
||||||
From 82691ece1ee9ac6dbc1a94a62b58ae97aa294be6 Mon Sep 17 00:00:00 2001
|
From d194cb9b25a0b91d20c348eb2aa1d95d5e9bd474 Mon Sep 17 00:00:00 2001
|
||||||
From: Fijxu <fijxu@nadeko.net>
|
From: Fijxu <fijxu@nadeko.net>
|
||||||
Date: Mon, 24 Mar 2025 18:44:10 -0300
|
Date: Mon, 24 Mar 2025 18:44:10 -0300
|
||||||
Subject: [PATCH 1/8] feat: add support for an external videoplayback proxy
|
Subject: [PATCH 1/9] feat: add support for an external videoplayback proxy
|
||||||
|
|
||||||
---
|
---
|
||||||
config/config.example.toml | 1 +
|
config/config.example.toml | 1 +
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
From fa5e74b3dc1cda34a6b32ac26be3f81d67531353 Mon Sep 17 00:00:00 2001
|
From 680ed30e4d25dfbf32da9c49bb5a27f8c5aa7114 Mon Sep 17 00:00:00 2001
|
||||||
From: Fijxu <fijxu@nadeko.net>
|
From: Fijxu <fijxu@nadeko.net>
|
||||||
Date: Mon, 24 Mar 2025 18:52:53 -0300
|
Date: Mon, 24 Mar 2025 18:52:53 -0300
|
||||||
Subject: [PATCH 2/8] feat: report the external videoplayback proxy via /info
|
Subject: [PATCH 2/9] feat: report the external videoplayback proxy via /info
|
||||||
endpoint
|
endpoint
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
From 0e168a21d86aef874351e55dbdbbcdf2a98b1639 Mon Sep 17 00:00:00 2001
|
From 912f7b7c230e9e3a97d5f678f5b93898951c5353 Mon Sep 17 00:00:00 2001
|
||||||
From: Fijxu <fijxu@nadeko.net>
|
From: Fijxu <fijxu@nadeko.net>
|
||||||
Date: Mon, 24 Mar 2025 19:02:01 -0300
|
Date: Mon, 24 Mar 2025 19:02:01 -0300
|
||||||
Subject: [PATCH 3/8] feat: add resolution limit on DASH streams to save
|
Subject: [PATCH 3/9] feat: add resolution limit on DASH streams to save
|
||||||
bandwidth
|
bandwidth
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
From 58ef80353e51bcc74ecb52a0b5056d65b878fef1 Mon Sep 17 00:00:00 2001
|
From d040970de1e644f0b3234db892359297f922fb72 Mon Sep 17 00:00:00 2001
|
||||||
From: Fijxu <fijxu@nadeko.net>
|
From: Fijxu <fijxu@nadeko.net>
|
||||||
Date: Mon, 24 Mar 2025 19:06:04 -0300
|
Date: Mon, 24 Mar 2025 19:06:04 -0300
|
||||||
Subject: [PATCH 4/8] feat: add env variable to set verify_requests
|
Subject: [PATCH 4/9] feat: add env variable to set verify_requests
|
||||||
|
|
||||||
---
|
---
|
||||||
src/lib/helpers/config.ts | 4 +++-
|
src/lib/helpers/config.ts | 4 +++-
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
From ca8941952b3788cb422119505d0fd430899d4184 Mon Sep 17 00:00:00 2001
|
From 32abcfb826715a756db497c00d6e840f758055b8 Mon Sep 17 00:00:00 2001
|
||||||
From: Fijxu <fijxu@nadeko.net>
|
From: Fijxu <fijxu@nadeko.net>
|
||||||
Date: Mon, 24 Mar 2025 19:20:52 -0300
|
Date: Mon, 24 Mar 2025 19:20:52 -0300
|
||||||
Subject: [PATCH 5/8] feat: add support for multiple proxies
|
Subject: [PATCH 5/9] feat: add support for multiple proxies
|
||||||
|
|
||||||
---
|
---
|
||||||
src/lib/helpers/getFetchClient.ts | 17 ++++++++++++++++-
|
src/lib/helpers/getFetchClient.ts | 17 ++++++++++++++++-
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
From 7dbb4046d6df30eb967283d2685b49b2873d6ad2 Mon Sep 17 00:00:00 2001
|
From ff34450a415cfdc0bee2c75090d4cbe3b33d3fdf Mon Sep 17 00:00:00 2001
|
||||||
From: Fijxu <fijxu@nadeko.net>
|
From: Fijxu <fijxu@nadeko.net>
|
||||||
Date: Mon, 24 Mar 2025 19:37:34 -0300
|
Date: Mon, 24 Mar 2025 19:37:34 -0300
|
||||||
Subject: [PATCH 6/8] ci: update deno to 2.2.4
|
Subject: [PATCH 6/9] ci: update deno to 2.2.4
|
||||||
|
|
||||||
---
|
---
|
||||||
Dockerfile | 2 +-
|
Dockerfile | 2 +-
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
From 5b11aef97d53e3b6f1d1bcd32b0ded153de6ffd4 Mon Sep 17 00:00:00 2001
|
From 1809787ec91c57bb273a26f42f56bb9c8450789e Mon Sep 17 00:00:00 2001
|
||||||
From: Fijxu <fijxu@nadeko.net>
|
From: Fijxu <fijxu@nadeko.net>
|
||||||
Date: Mon, 24 Mar 2025 20:06:47 -0300
|
Date: Mon, 24 Mar 2025 20:06:47 -0300
|
||||||
Subject: [PATCH 7/8] fix: temporary player_id override until an official fix
|
Subject: [PATCH 7/9] fix: temporary player_id override until an official fix
|
||||||
cames out
|
cames out
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
From a53c64192297ce1747d697321b674f303e4c0273 Mon Sep 17 00:00:00 2001
|
From b5318804619e1061695ae2e62b77f8aef261a7e5 Mon Sep 17 00:00:00 2001
|
||||||
From: Fijxu <fijxu@nadeko.net>
|
From: Fijxu <fijxu@nadeko.net>
|
||||||
Date: Mon, 24 Mar 2025 20:22:19 -0300
|
Date: Mon, 24 Mar 2025 20:22:19 -0300
|
||||||
Subject: [PATCH 8/8] fix: cut off secret_key to 16 characters
|
Subject: [PATCH 8/9] fix: cut off secret_key to 16 characters
|
||||||
|
|
||||||
---
|
---
|
||||||
src/lib/helpers/verifyRequest.ts | 2 +-
|
src/lib/helpers/verifyRequest.ts | 2 +-
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
From 4c8128d7c61d09c486056a6a3d0df119c76a8393 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Fijxu <fijxu@nadeko.net>
|
||||||
|
Date: Mon, 24 Mar 2025 20:34:33 -0300
|
||||||
|
Subject: [PATCH 9/9] feat: add option to disable potoken generation check
|
||||||
|
|
||||||
|
---
|
||||||
|
config/config.example.toml | 1 +
|
||||||
|
src/lib/helpers/config.ts | 1 +
|
||||||
|
src/lib/jobs/potoken.ts | 80 ++++++++++++++++++++------------------
|
||||||
|
3 files changed, 44 insertions(+), 38 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config/config.example.toml b/config/config.example.toml
|
||||||
|
index a3c73be..4c04ee3 100644
|
||||||
|
--- a/config/config.example.toml
|
||||||
|
+++ b/config/config.example.toml
|
||||||
|
@@ -51,6 +51,7 @@
|
||||||
|
# [jobs.youtube_session]
|
||||||
|
# po_token_enabled = true # whether to generate PO tokens
|
||||||
|
# frequency = "*/5 * * * *" # frequency of PO token refresh in cron format
|
||||||
|
+# po_token_check = false # whether to check if the PO token is valid or not
|
||||||
|
|
||||||
|
# [youtube_session]
|
||||||
|
# oauth_enabled = false
|
||||||
|
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
|
||||||
|
index 05748f0..271c17a 100644
|
||||||
|
--- a/src/lib/helpers/config.ts
|
||||||
|
+++ b/src/lib/helpers/config.ts
|
||||||
|
@@ -39,6 +39,7 @@ const ConfigSchema = z.object({
|
||||||
|
youtube_session: z.object({
|
||||||
|
po_token_enabled: z.boolean().default(true),
|
||||||
|
frequency: z.string().default("*/5 * * * *"),
|
||||||
|
+ po_token_check: z.boolean().default(true),
|
||||||
|
}).strict().default({}),
|
||||||
|
}).strict().default({}),
|
||||||
|
youtube_session: z.object({
|
||||||
|
diff --git a/src/lib/jobs/potoken.ts b/src/lib/jobs/potoken.ts
|
||||||
|
index 233ac32..c7994c5 100644
|
||||||
|
--- a/src/lib/jobs/potoken.ts
|
||||||
|
+++ b/src/lib/jobs/potoken.ts
|
||||||
|
@@ -140,46 +140,50 @@ export const poTokenGenerate = async (
|
||||||
|
instantiatedInnertubeClient.session.player = player;
|
||||||
|
instantiatedInnertubeClient.session.player.po_token = sessionPoToken;
|
||||||
|
|
||||||
|
- try {
|
||||||
|
- const feed = await instantiatedInnertubeClient.getTrending();
|
||||||
|
- // get all videos and shuffle them randomly to avoid using the same trending video over and over
|
||||||
|
- const videos = feed.videos
|
||||||
|
- .filter((video) => video.type === "Video")
|
||||||
|
- .map((value) => ({ value, sort: Math.random() }))
|
||||||
|
- .sort((a, b) => a.sort - b.sort)
|
||||||
|
- .map(({ value }) => value);
|
||||||
|
-
|
||||||
|
- const video = videos.find((video) => "id" in video);
|
||||||
|
- if (!video) {
|
||||||
|
- throw new Error("no videos with id found in trending");
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- const youtubePlayerResponseJson = await youtubePlayerParsing({
|
||||||
|
- innertubeClient: instantiatedInnertubeClient,
|
||||||
|
- videoId: video.id,
|
||||||
|
- config,
|
||||||
|
- tokenMinter: integrityTokenBasedMinter,
|
||||||
|
- overrideCache: true,
|
||||||
|
- });
|
||||||
|
- const videoInfo = youtubeVideoInfo(
|
||||||
|
- instantiatedInnertubeClient,
|
||||||
|
- youtubePlayerResponseJson,
|
||||||
|
- );
|
||||||
|
- const validFormat = videoInfo.streaming_data?.adaptive_formats[0];
|
||||||
|
- if (!validFormat) {
|
||||||
|
- throw new Error(
|
||||||
|
- "failed to find valid video with adaptive format to check token against",
|
||||||
|
- );
|
||||||
|
- }
|
||||||
|
- const result = await fetchImpl(validFormat?.url, { method: "HEAD" });
|
||||||
|
- if (result.status !== 200) {
|
||||||
|
- throw new Error(
|
||||||
|
- `did not get a 200 when checking video, got ${result.status} instead`,
|
||||||
|
+ if (config.jobs.youtube_session.po_token_check) {
|
||||||
|
+ try {
|
||||||
|
+ const feed = await instantiatedInnertubeClient.getTrending();
|
||||||
|
+ // get all videos and shuffle them randomly to avoid using the same trending video over and over
|
||||||
|
+ const videos = feed.videos
|
||||||
|
+ .filter((video) => video.type === "Video")
|
||||||
|
+ .map((value) => ({ value, sort: Math.random() }))
|
||||||
|
+ .sort((a, b) => a.sort - b.sort)
|
||||||
|
+ .map(({ value }) => value);
|
||||||
|
+
|
||||||
|
+ const video = videos.find((video) => "id" in video);
|
||||||
|
+ if (!video) {
|
||||||
|
+ throw new Error("no videos with id found in trending");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ const youtubePlayerResponseJson = await youtubePlayerParsing({
|
||||||
|
+ innertubeClient: instantiatedInnertubeClient,
|
||||||
|
+ videoId: video.id,
|
||||||
|
+ config,
|
||||||
|
+ tokenMinter: integrityTokenBasedMinter,
|
||||||
|
+ overrideCache: true,
|
||||||
|
+ });
|
||||||
|
+ const videoInfo = youtubeVideoInfo(
|
||||||
|
+ instantiatedInnertubeClient,
|
||||||
|
+ youtubePlayerResponseJson,
|
||||||
|
);
|
||||||
|
+ const validFormat = videoInfo.streaming_data?.adaptive_formats[0];
|
||||||
|
+ if (!validFormat) {
|
||||||
|
+ throw new Error(
|
||||||
|
+ "failed to find valid video with adaptive format to check token against",
|
||||||
|
+ );
|
||||||
|
+ }
|
||||||
|
+ const result = await fetchImpl(validFormat?.url, {
|
||||||
|
+ method: "HEAD",
|
||||||
|
+ });
|
||||||
|
+ if (result.status !== 200) {
|
||||||
|
+ throw new Error(
|
||||||
|
+ `did not get a 200 when checking video, got ${result.status} instead`,
|
||||||
|
+ );
|
||||||
|
+ }
|
||||||
|
+ } catch (err) {
|
||||||
|
+ console.log("Failed to get valid PO token, will retry", { err });
|
||||||
|
+ throw err;
|
||||||
|
}
|
||||||
|
- } catch (err) {
|
||||||
|
- console.log("Failed to get valid PO token, will retry", { err });
|
||||||
|
- throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
--
|
||||||
|
2.49.0
|
||||||
|
|
Loading…
Add table
Reference in a new issue