diff --git a/src/invidious/videos/description.cr b/src/invidious/videos/description.cr index 2017955dc..0a9d84f88 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"]?