Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 12s
64 lines
2.5 KiB
Diff
64 lines
2.5 KiB
Diff
From 896f8566b909ff97c52b8ae890b57e412e9e3db2 Mon Sep 17 00:00:00 2001
|
|
From: Fijxu <fijxu@nadeko.net>
|
|
Date: Tue, 25 Mar 2025 00:04:47 -0300
|
|
Subject: [PATCH 08/19] add proxy retries on innertube error
|
|
|
|
---
|
|
src/lib/helpers/config.ts | 1 +
|
|
src/lib/helpers/youtubePlayerHandling.ts | 23 ++++++++++++++++++++++-
|
|
2 files changed, 23 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
|
|
index 6004753..c840ce4 100644
|
|
--- a/src/lib/helpers/config.ts
|
|
+++ b/src/lib/helpers/config.ts
|
|
@@ -40,6 +40,7 @@ export const ConfigSchema = z.object({
|
|
external_videoplayback_proxy: z.string().default(
|
|
Deno.env.get("EXTERNAL_VIDEOPLAYBACK_PROXY") || "",
|
|
),
|
|
+ max_proxy_retries: z.number().default(Number(Deno.env.get("MAX_PROXY_RETIRES") || 5)),
|
|
}).strict().default({}),
|
|
jobs: z.object({
|
|
youtube_session: z.object({
|
|
diff --git a/src/lib/helpers/youtubePlayerHandling.ts b/src/lib/helpers/youtubePlayerHandling.ts
|
|
index 4c9ab51..792ba54 100644
|
|
--- a/src/lib/helpers/youtubePlayerHandling.ts
|
|
+++ b/src/lib/helpers/youtubePlayerHandling.ts
|
|
@@ -43,12 +43,33 @@ export const youtubePlayerParsing = async ({
|
|
if (videoCached != null && cacheEnabled) {
|
|
return JSON.parse(new TextDecoder().decode(decompress(videoCached)));
|
|
} else {
|
|
- const youtubePlayerResponse = await youtubePlayerReq(
|
|
+ let youtubePlayerResponse = await youtubePlayerReq(
|
|
innertubeClient,
|
|
videoId,
|
|
config,
|
|
tokenMinter,
|
|
);
|
|
+
|
|
+ const maxRetries = config.networking.max_proxy_retries;
|
|
+ for (let retries = 1; retries <= (maxRetries as number); retries++) {
|
|
+ if (
|
|
+ !youtubePlayerResponse.data.playabilityStatus?.errorScreen
|
|
+ ?.playerErrorMessageRenderer?.subreason?.runs?.[0]?.text
|
|
+ ?.includes("This helps protect our community")
|
|
+ ) {
|
|
+ break;
|
|
+ }
|
|
+ console.log(
|
|
+ `[DEBUG] Got 'This helps protect our community', retrying request for ${videoId}. Retry ${retries} of ${maxRetries}`,
|
|
+ );
|
|
+ youtubePlayerResponse = await youtubePlayerReq(
|
|
+ innertubeClient,
|
|
+ videoId,
|
|
+ config,
|
|
+ tokenMinter,
|
|
+ );
|
|
+ }
|
|
+
|
|
const videoData = youtubePlayerResponse.data;
|
|
|
|
const video = new YT.VideoInfo(
|
|
--
|
|
2.49.0
|
|
|