From f318c94bd80388cdb671d529bed27181a46717da Mon Sep 17 00:00:00 2001 From: Emilien Devos <4016501+unixfox@users.noreply.github.com> Date: Tue, 24 Dec 2024 20:57:13 +0100 Subject: [PATCH 1/4] include alr=false in order to disable application redirect for now fixes #30 --- src/lib/helpers/youtubePlayerHandling.ts | 10 ++++++++++ src/routes/videoPlaybackProxy.ts | 4 ---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/helpers/youtubePlayerHandling.ts b/src/lib/helpers/youtubePlayerHandling.ts index 11b7ae3..c91a8f9 100644 --- a/src/lib/helpers/youtubePlayerHandling.ts +++ b/src/lib/helpers/youtubePlayerHandling.ts @@ -77,6 +77,11 @@ export const youtubePlayerParsing = async ( delete videoData.streamingData.formats[index] .signatureCipher; } + if (videoData.streamingData.formats[index].url.includes("alr=true")) { + videoData.streamingData.formats[index].url.replace("alr=true", "alr=false"); + } else { + videoData.streamingData.formats[index].url += "&alr=false"; + } } for ( const [index, adaptive_format] of streamingData @@ -96,6 +101,11 @@ export const youtubePlayerParsing = async ( delete videoData.streamingData.adaptiveFormats[index] .signatureCipher; } + if (videoData.streamingData.adaptiveFormats[index].url.includes("alr=true")) { + videoData.streamingData.adaptiveFormats[index].url.replace("alr=true", "alr=false"); + } else { + videoData.streamingData.adaptiveFormats[index].url += "&alr=false"; + } } } } diff --git a/src/routes/videoPlaybackProxy.ts b/src/routes/videoPlaybackProxy.ts index 9f52a87..ab84622 100644 --- a/src/routes/videoPlaybackProxy.ts +++ b/src/routes/videoPlaybackProxy.ts @@ -52,10 +52,6 @@ videoPlaybackProxy.get("/", async (c) => { // deno-lint-ignore prefer-const let queryParams = new URLSearchParams(urlReq.search); queryParams.delete("host"); - // alr parameter is only for WEB/HTML5 clients - if (client.includes("WEB")) { - queryParams.append("alr", "yes"); - } if (rangeHeader) { queryParams.append( "range", From fd76a5193364f60cdcd4bfc988292a1f328f750d Mon Sep 17 00:00:00 2001 From: Emilien Devos <4016501+unixfox@users.noreply.github.com> Date: Tue, 24 Dec 2024 23:19:29 +0100 Subject: [PATCH 2/4] true to yes and false to no --- src/lib/helpers/youtubePlayerHandling.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/helpers/youtubePlayerHandling.ts b/src/lib/helpers/youtubePlayerHandling.ts index c91a8f9..4d7cf01 100644 --- a/src/lib/helpers/youtubePlayerHandling.ts +++ b/src/lib/helpers/youtubePlayerHandling.ts @@ -77,10 +77,10 @@ export const youtubePlayerParsing = async ( delete videoData.streamingData.formats[index] .signatureCipher; } - if (videoData.streamingData.formats[index].url.includes("alr=true")) { - videoData.streamingData.formats[index].url.replace("alr=true", "alr=false"); + if (videoData.streamingData.formats[index].url.includes("alr=yes")) { + videoData.streamingData.formats[index].url.replace("alr=yes", "alr=no"); } else { - videoData.streamingData.formats[index].url += "&alr=false"; + videoData.streamingData.formats[index].url += "&alr=no"; } } for ( @@ -101,10 +101,10 @@ export const youtubePlayerParsing = async ( delete videoData.streamingData.adaptiveFormats[index] .signatureCipher; } - if (videoData.streamingData.adaptiveFormats[index].url.includes("alr=true")) { - videoData.streamingData.adaptiveFormats[index].url.replace("alr=true", "alr=false"); + if (videoData.streamingData.adaptiveFormats[index].url.includes("alr=yes")) { + videoData.streamingData.adaptiveFormats[index].url.replace("alr=yes", "alr=no"); } else { - videoData.streamingData.adaptiveFormats[index].url += "&alr=false"; + videoData.streamingData.adaptiveFormats[index].url += "&alr=no"; } } } From f89f41380a1964b8bb6e73b10f1f55ed26f581df Mon Sep 17 00:00:00 2001 From: Emilien Devos <4016501+unixfox@users.noreply.github.com> Date: Wed, 25 Dec 2024 10:13:37 +0100 Subject: [PATCH 3/4] Revert "workaround issue with TV not returning any shortDescription" This reverts commit 6ca59654baeceaa13f5c5637937bdffbe7d7b17a. --- src/lib/helpers/youtubePlayerHandling.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/lib/helpers/youtubePlayerHandling.ts b/src/lib/helpers/youtubePlayerHandling.ts index 4d7cf01..8b6b717 100644 --- a/src/lib/helpers/youtubePlayerHandling.ts +++ b/src/lib/helpers/youtubePlayerHandling.ts @@ -45,11 +45,6 @@ export const youtubePlayerParsing = async ( const streamingData = video.streaming_data; - // WORKAROUND the issue with TV client not returning any short description - if (!videoData.videoDetails.shortDescription) { - videoData.videoDetails.shortDescription = ""; - } - // Modify the original YouTube response to include deciphered URLs if (streamingData && videoData && videoData.streamingData) { const ecatcherServiceTracking = videoData.responseContext From d53d10b774c624091480cd8146d48f7fc4377b32 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Wed, 25 Dec 2024 08:55:41 -0300 Subject: [PATCH 4/4] add health endpoint for healthchecks (#27) --- src/routes/health.ts | 12 ++++++++++++ src/routes/index.ts | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 src/routes/health.ts diff --git a/src/routes/health.ts b/src/routes/health.ts new file mode 100644 index 0000000..517a991 --- /dev/null +++ b/src/routes/health.ts @@ -0,0 +1,12 @@ +import { Hono } from "hono"; + +const health = new Hono(); + +health.get("/", () => { + return new Response("OK", { + status: 200, + headers: { "Content-Type": "text/plain" }, + }); +}); + +export default health; \ No newline at end of file diff --git a/src/routes/index.ts b/src/routes/index.ts index e481268..5ad9258 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -7,6 +7,7 @@ import youtubeApiPlayer from "./youtube_api_routes/player.ts"; import invidiousRouteLatestVersion from "./invidious_routes/latestVersion.ts"; import invidiousRouteDashManifest from "./invidious_routes/dashManifest.ts"; import videoPlaybackProxy from "./videoPlaybackProxy.ts"; +import health from "./health.ts"; export const routes = (app: Hono, konfigStore: Store>) => { app.use("*", logger()); @@ -22,4 +23,5 @@ export const routes = (app: Hono, konfigStore: Store>) = app.route("/latest_version", invidiousRouteLatestVersion); app.route("/api/manifest/dash/id", invidiousRouteDashManifest); app.route("/videoplayback", videoPlaybackProxy); + app.route("/healthz", health); };