From d420741cc15dce656da641f5143120ec88e59bc8 Mon Sep 17 00:00:00 2001
From: chunky programmer <78101139+ChunkyProgrammer@users.noreply.github.com>
Date: Wed, 19 Apr 2023 20:59:06 -0400
Subject: [PATCH] Allow channel urls to be displayed in YT description
---
src/invidious/videos/description.cr | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/invidious/videos/description.cr b/src/invidious/videos/description.cr
index 2017955d..0a9d84f8 100644
--- a/src/invidious/videos/description.cr
+++ b/src/invidious/videos/description.cr
@@ -6,13 +6,19 @@ def parse_command(command : JSON::Any?, string : String) : String?
# 3rd party URL, extract original URL from YouTube tracking URL
if url_endpoint = on_tap.try &.["urlEndpoint"]?
- youtube_url = URI.parse url_endpoint["url"].as_s
-
- original_url = youtube_url.query_params["q"]?
- if original_url.nil?
- return ""
+ if url_endpoint["url"].as_s.includes? "youtube.com/redirect"
+ youtube_url = URI.parse url_endpoint["url"].as_s
+ original_url = youtube_url.query_params["q"]?
+ if original_url.nil?
+ return ""
+ else
+ return "#{original_url}"
+ end
else
- return "#{original_url}"
+ # not a redirect url, some first party url
+ # see https://github.com/iv-org/invidious/issues/3751
+ first_party_url = url_endpoint["url"].as_s
+ return "#{first_party_url}"
end
# 1st party watch URL
elsif watch_endpoint = on_tap.try &.["watchEndpoint"]?