diff --git a/patches/0001-ci-update-deno-to-2.2.5.patch b/patches/0001-ci-update-deno-to-2.2.9.patch similarity index 63% rename from patches/0001-ci-update-deno-to-2.2.5.patch rename to patches/0001-ci-update-deno-to-2.2.9.patch index 97e8ab0..ec6eb38 100644 --- a/patches/0001-ci-update-deno-to-2.2.5.patch +++ b/patches/0001-ci-update-deno-to-2.2.9.patch @@ -1,19 +1,19 @@ -From c83645ec3e6d0a53ab20f0eb9e0b16e11f6d2fed Mon Sep 17 00:00:00 2001 +From 304a11d7dbb5ea7b2a0a0807b72b7a8fd412fe45 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 24 Mar 2025 19:37:34 -0300 -Subject: [PATCH 01/13] ci: update deno to 2.2.5 +Subject: [PATCH 01/13] ci: update deno to 2.2.9 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile -index 04b74c0..0f9f933 100644 +index 04b74c0..0d45468 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM denoland/deno:debian-2.1.4 AS builder -+FROM denoland/deno:debian-2.2.5 AS builder ++FROM denoland/deno:debian-2.2.9 AS builder ARG TINI_VERSION=0.19.0 diff --git a/patches/0002-feat-add-support-for-an-external-videoplayback-proxy.patch b/patches/0002-feat-add-support-for-an-external-videoplayback-proxy.patch index aae374f..71a7b67 100644 --- a/patches/0002-feat-add-support-for-an-external-videoplayback-proxy.patch +++ b/patches/0002-feat-add-support-for-an-external-videoplayback-proxy.patch @@ -1,4 +1,4 @@ -From c87979c26380ed00e9894396a3d15d6c0d7059e4 Mon Sep 17 00:00:00 2001 +From 7cb6f3aef050b13290bd2184f26727d15b8b1399 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 24 Mar 2025 18:44:10 -0300 Subject: [PATCH 02/13] feat: add support for an external videoplayback proxy diff --git a/patches/0003-feat-report-the-external-videoplayback-proxy-via-inf.patch b/patches/0003-feat-report-the-external-videoplayback-proxy-via-inf.patch index 62c57f8..7156796 100644 --- a/patches/0003-feat-report-the-external-videoplayback-proxy-via-inf.patch +++ b/patches/0003-feat-report-the-external-videoplayback-proxy-via-inf.patch @@ -1,4 +1,4 @@ -From 69060577293547a049f37e8319661d139bc0d8e0 Mon Sep 17 00:00:00 2001 +From 6bf25c88d4201ae64b8995999f68f5d8041068d8 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 24 Mar 2025 18:52:53 -0300 Subject: [PATCH 03/13] feat: report the external videoplayback proxy via /info diff --git a/patches/0004-feat-add-resolution-limit-on-DASH-streams-to-save-ba.patch b/patches/0004-feat-add-resolution-limit-on-DASH-streams-to-save-ba.patch index 96131a4..4d29761 100644 --- a/patches/0004-feat-add-resolution-limit-on-DASH-streams-to-save-ba.patch +++ b/patches/0004-feat-add-resolution-limit-on-DASH-streams-to-save-ba.patch @@ -1,4 +1,4 @@ -From 84db2add0f0c4e3ab299d999e85966029f8d3c53 Mon Sep 17 00:00:00 2001 +From 78e38dca6a6aa534a82f9baca9a6bdeb13c463b3 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 24 Mar 2025 19:02:01 -0300 Subject: [PATCH 04/13] feat: add resolution limit on DASH streams to save diff --git a/patches/0005-feat-add-env-variable-to-set-verify_requests.patch b/patches/0005-feat-add-env-variable-to-set-verify_requests.patch index e54b886..ca49ed0 100644 --- a/patches/0005-feat-add-env-variable-to-set-verify_requests.patch +++ b/patches/0005-feat-add-env-variable-to-set-verify_requests.patch @@ -1,4 +1,4 @@ -From bba074b050e57a1c59e97a966568eb98de192606 Mon Sep 17 00:00:00 2001 +From ccbac1fa1a5e2d003e8781f1a40ce2c8921e750b Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 24 Mar 2025 19:06:04 -0300 Subject: [PATCH 05/13] feat: add env variable to set verify_requests diff --git a/patches/0006-feat-add-support-for-multiple-proxies.patch b/patches/0006-feat-add-support-for-multiple-proxies.patch index 67e3035..2fd89ce 100644 --- a/patches/0006-feat-add-support-for-multiple-proxies.patch +++ b/patches/0006-feat-add-support-for-multiple-proxies.patch @@ -1,4 +1,4 @@ -From e2828064cea085c5994080cf73e162a62f86403f Mon Sep 17 00:00:00 2001 +From 118a43eb29e5c0d177f24b397b6cea03d1f9f81f Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 24 Mar 2025 19:20:52 -0300 Subject: [PATCH 06/13] feat: add support for multiple proxies diff --git a/patches/0007-feat-add-option-to-disable-potoken-generation-check.patch b/patches/0007-feat-add-option-to-disable-potoken-generation-check.patch index 2c6f1a9..35d9b97 100644 --- a/patches/0007-feat-add-option-to-disable-potoken-generation-check.patch +++ b/patches/0007-feat-add-option-to-disable-potoken-generation-check.patch @@ -1,13 +1,13 @@ -From 96220305843a6fbfb99387b0adcc1a7e5d2a3d6f Mon Sep 17 00:00:00 2001 +From 366732c6fec10c7efe360e208974352b93078850 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 24 Mar 2025 20:34:33 -0300 Subject: [PATCH 07/13] feat: add option to disable potoken generation check --- - config/config.example.toml | 1 + - src/lib/helpers/config.ts | 9 +++++++++ - src/lib/jobs/potoken.ts | 4 +++- - 3 files changed, 13 insertions(+), 1 deletion(-) + config/config.example.toml | 1 + + src/lib/helpers/config.ts | 9 +++++ + src/lib/jobs/potoken.ts | 80 ++++++++++++++++++++------------------ + 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/config/config.example.toml b/config/config.example.toml index 8e2af1c..b1cb4ee 100644 @@ -42,20 +42,98 @@ index cd0489d..6004753 100644 }).strict().default({}), youtube_session: z.object({ diff --git a/src/lib/jobs/potoken.ts b/src/lib/jobs/potoken.ts -index c2b9441..b8be39b 100644 +index c2b9441..9fd4101 100644 --- a/src/lib/jobs/potoken.ts +++ b/src/lib/jobs/potoken.ts -@@ -177,7 +177,9 @@ async function checkToken({ - "failed to find valid video with adaptive format to check token against", - ); - } +@@ -145,46 +145,50 @@ async function checkToken({ + }) { + const fetchImpl = getFetchClient(config); + +- 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"); +- } ++ 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, +- metrics, +- 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" }); -+ 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 (result.status !== 200) { +- throw new Error( +- `did not get a 200 when checking video, got ${result.status} instead`, ++ const youtubePlayerResponseJson = await youtubePlayerParsing({ ++ innertubeClient: instantiatedInnertubeClient, ++ videoId: video.id, ++ config, ++ tokenMinter: integrityTokenBasedMinter, ++ metrics, ++ 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; + } + } -- 2.49.0 diff --git a/patches/0008-add-proxy-retries-on-innertube-error.patch b/patches/0008-add-proxy-retries-on-innertube-error.patch index a5c1a26..750d65a 100644 --- a/patches/0008-add-proxy-retries-on-innertube-error.patch +++ b/patches/0008-add-proxy-retries-on-innertube-error.patch @@ -1,4 +1,4 @@ -From 8440076ee1af7a3088938a9e481afbaede9b5750 Mon Sep 17 00:00:00 2001 +From 14316bc947ac4445465fd8a71bdca3dee2eebb37 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 25 Mar 2025 00:04:47 -0300 Subject: [PATCH 08/13] add proxy retries on innertube error diff --git a/patches/0009-add-metrics-for-proxy-retries.patch b/patches/0009-add-metrics-for-proxy-retries.patch index 5c5dca8..09e4ca7 100644 --- a/patches/0009-add-metrics-for-proxy-retries.patch +++ b/patches/0009-add-metrics-for-proxy-retries.patch @@ -1,4 +1,4 @@ -From 79ef8ba531499997aea3e74415a2e8c315080e59 Mon Sep 17 00:00:00 2001 +From 8abaf38caf956720e39c32425c69452472cffecc Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 25 Mar 2025 00:07:28 -0300 Subject: [PATCH 09/13] add metrics for proxy retries diff --git a/patches/0010-fix-fix-tokio-overflow-on-compile.patch b/patches/0010-fix-fix-tokio-overflow-on-compile.patch index 164ceda..b03acc8 100644 --- a/patches/0010-fix-fix-tokio-overflow-on-compile.patch +++ b/patches/0010-fix-fix-tokio-overflow-on-compile.patch @@ -1,4 +1,4 @@ -From 34010c0db0dbbd9f0831eb44ed22ff728e7fe0e1 Mon Sep 17 00:00:00 2001 +From e4b515fe5b7819b5e1e210f5648e7163ea7236cc Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 25 Mar 2025 00:24:07 -0300 Subject: [PATCH 10/13] fix: fix tokio overflow on compile @@ -8,11 +8,11 @@ Subject: [PATCH 10/13] fix: fix tokio overflow on compile 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile -index 0f9f933..99fce38 100644 +index 0d45468..370678d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ - FROM denoland/deno:debian-2.2.5 AS builder + FROM denoland/deno:debian-2.2.9 AS builder +ENV RUST_MIN_STACK=9999999999 + diff --git a/patches/0011-Add-environment-variable-for-youtube_session.frequen.patch b/patches/0011-Add-environment-variable-for-youtube_session.frequen.patch index 2100546..45bd25b 100644 --- a/patches/0011-Add-environment-variable-for-youtube_session.frequen.patch +++ b/patches/0011-Add-environment-variable-for-youtube_session.frequen.patch @@ -1,4 +1,4 @@ -From 9bfe190249affbdb92ecfa7bb575a2948682f836 Mon Sep 17 00:00:00 2001 +From f700501126aeb9517e679055e7f6b8e626455fa7 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Wed, 26 Mar 2025 12:24:49 -0300 Subject: [PATCH 11/13] Add environment variable for youtube_session.frequency diff --git a/patches/0012-add-option-to-disable-logging.patch b/patches/0012-add-option-to-disable-logging.patch index 1341f7a..be93c45 100644 --- a/patches/0012-add-option-to-disable-logging.patch +++ b/patches/0012-add-option-to-disable-logging.patch @@ -1,4 +1,4 @@ -From 0916b71023628157a597339e4a0481c5dec1315d Mon Sep 17 00:00:00 2001 +From 32afd34c9d071c36e9ebcdb3fd637b2041e879df Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 8 Apr 2025 02:21:10 -0400 Subject: [PATCH 12/13] add option to disable logging diff --git a/patches/0013-metrics-track-unidentified-innertube-errors.patch b/patches/0013-metrics-track-unidentified-innertube-errors.patch index ecc7dfb..4a877e3 100644 --- a/patches/0013-metrics-track-unidentified-innertube-errors.patch +++ b/patches/0013-metrics-track-unidentified-innertube-errors.patch @@ -1,4 +1,4 @@ -From e3cfa0f2dc3f7fc74c90db9f5636e7b4c43eb0c8 Mon Sep 17 00:00:00 2001 +From e2b7c8156fbc137f621036b2dd5fa4d34e383a0a Mon Sep 17 00:00:00 2001 From: Fijxu Date: Wed, 9 Apr 2025 13:37:16 -0400 Subject: [PATCH 13/13] metrics: track unidentified innertube errors