From f602e857eb57c472fc5aa660c2ce8b433c1d6246 Mon Sep 17 00:00:00 2001 From: TeamMasse Date: Thu, 30 Jan 2025 22:02:15 +0100 Subject: [PATCH 1/7] do it --- src/invidious/routes/errors.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/invidious/routes/errors.cr b/src/invidious/routes/errors.cr index 1e9ab44e..0dd99716 100644 --- a/src/invidious/routes/errors.cr +++ b/src/invidious/routes/errors.cr @@ -15,10 +15,10 @@ module Invidious::Routes::ErrorRoutes response = YT_POOL.client &.get(URI.parse(response.headers["Location"]).request_target) end - if response.body.empty? - env.response.headers["Location"] = "/" - haltf env, status_code: 302 - end + #if response.body.empty? + # env.response.headers["Location"] = "/" + # haltf env, status_code: 302 + #end html = XML.parse_html(response.body) ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1] From ba66d62d8eb43a3a46b35f4a15fdcec045ecda83 Mon Sep 17 00:00:00 2001 From: TeamMasse Date: Thu, 30 Jan 2025 22:11:27 +0100 Subject: [PATCH 2/7] changed hmac key --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index afda8726..4b39a1a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,7 +30,7 @@ services: # domain: # https_only: false # statistics_enabled: false - hmac_key: "CHANGE_ME!!" + hmac_key: "Ahyie5aiz6ahCh2naex4" healthcheck: test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/trending || exit 1 interval: 30s From bea747c3c0cb8c46b71b6780546cd40534e4b424 Mon Sep 17 00:00:00 2001 From: TeamMasse Date: Thu, 30 Jan 2025 22:22:31 +0100 Subject: [PATCH 3/7] comment out --- docker-compose.yml | 1 + src/invidious/routes/errors.cr | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4b39a1a3..3092ac91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,6 +31,7 @@ services: # https_only: false # statistics_enabled: false hmac_key: "Ahyie5aiz6ahCh2naex4" + healthcheck: test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/trending || exit 1 interval: 30s diff --git a/src/invidious/routes/errors.cr b/src/invidious/routes/errors.cr index 0dd99716..5c8d7d06 100644 --- a/src/invidious/routes/errors.cr +++ b/src/invidious/routes/errors.cr @@ -20,13 +20,13 @@ module Invidious::Routes::ErrorRoutes # haltf env, status_code: 302 #end - html = XML.parse_html(response.body) - ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1] + #html = XML.parse_html(response.body) + #ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1] - if ucid - env.response.headers["Location"] = "/channel/#{ucid}" - haltf env, status_code: 302 - end + #if ucid + # env.response.headers["Location"] = "/channel/#{ucid}" + # haltf env, status_code: 302 + #end params = [] of String env.params.query.each do |k, v| From 3625ed36200769bf30bb803804de3c9edafae1a4 Mon Sep 17 00:00:00 2001 From: TeamMasse <106512658+TeamMasse@users.noreply.github.com> Date: Wed, 23 Apr 2025 22:56:29 +0200 Subject: [PATCH 4/7] fix #3933 swichted the order of checking for channel links and youtu.be/videoid short links to prevent redirecting to / because of empty response body for video --- src/invidious/routes/errors.cr | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/invidious/routes/errors.cr b/src/invidious/routes/errors.cr index 5c8d7d06..6d305578 100644 --- a/src/invidious/routes/errors.cr +++ b/src/invidious/routes/errors.cr @@ -15,19 +15,6 @@ module Invidious::Routes::ErrorRoutes response = YT_POOL.client &.get(URI.parse(response.headers["Location"]).request_target) end - #if response.body.empty? - # env.response.headers["Location"] = "/" - # haltf env, status_code: 302 - #end - - #html = XML.parse_html(response.body) - #ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1] - - #if ucid - # env.response.headers["Location"] = "/channel/#{ucid}" - # haltf env, status_code: 302 - #end - params = [] of String env.params.query.each do |k, v| params << "#{k}=#{v}" @@ -44,6 +31,19 @@ module Invidious::Routes::ErrorRoutes env.response.headers["Location"] = url haltf env, status_code: 302 end + + if response.body.empty? + env.response.headers["Location"] = "/" + haltf env, status_code: 302 + end + + html = XML.parse_html(response.body) + ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1] + + if ucid + env.response.headers["Location"] = "/channel/#{ucid}" + haltf env, status_code: 302 + end end env.response.headers["Location"] = "/" From 8984ad4c7d412281c843b8aaeb875e6b8cb31d7e Mon Sep 17 00:00:00 2001 From: TeamMasse <106512658+TeamMasse@users.noreply.github.com> Date: Wed, 23 Apr 2025 23:01:06 +0200 Subject: [PATCH 5/7] rechange hmac_key --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3092ac91..20ce31c8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,7 +30,7 @@ services: # domain: # https_only: false # statistics_enabled: false - hmac_key: "Ahyie5aiz6ahCh2naex4" + hmac_key: "CHANGE_ME!!" healthcheck: test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/trending || exit 1 From 96d7186cc8ca0a111e4d7e0ddf48600a8481faa5 Mon Sep 17 00:00:00 2001 From: TeamMasse <106512658+TeamMasse@users.noreply.github.com> Date: Wed, 23 Apr 2025 23:01:55 +0200 Subject: [PATCH 6/7] Update docker-compose.yml --- docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 20ce31c8..78fe159f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,8 +30,7 @@ services: # domain: # https_only: false # statistics_enabled: false - hmac_key: "CHANGE_ME!!" - + hmac_key: "CHANGE_ME!!" healthcheck: test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/trending || exit 1 interval: 30s From 247194c9945ebffa69428cd8302d52bab50583ca Mon Sep 17 00:00:00 2001 From: TeamMasse <106512658+TeamMasse@users.noreply.github.com> Date: Wed, 23 Apr 2025 23:03:02 +0200 Subject: [PATCH 7/7] Update docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 78fe159f..afda8726 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,7 +30,7 @@ services: # domain: # https_only: false # statistics_enabled: false - hmac_key: "CHANGE_ME!!" + hmac_key: "CHANGE_ME!!" healthcheck: test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/trending || exit 1 interval: 30s