From cc684ff0b1bfb358f5ef567865e23a532b168132 Mon Sep 17 00:00:00 2001 From: saltycrys <73420320+saltycrys@users.noreply.github.com> Date: Thu, 3 Dec 2020 21:02:52 +0100 Subject: [PATCH] Fix redirect channels Redirect channels may use JS to redirect now, instead of only a response header as it used to be. This fix reads the channel to redirect to from `ytInitialData`. --- src/invidious/channels.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index 93507c56..444a6eda 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -801,6 +801,10 @@ def get_about_info(ucid, locale) raise InfoException.new(error_message) end + if browse_endpoint = initdata["onResponseReceivedActions"]?.try &.[0]?.try &.["navigateAction"]?.try &.["endpoint"]?.try &.["browseEndpoint"]? + raise ChannelRedirect.new(channel_id: browse_endpoint["browseId"].to_s) + end + author = initdata["metadata"]["channelMetadataRenderer"]["title"].as_s author_url = initdata["metadata"]["channelMetadataRenderer"]["channelUrl"].as_s author_thumbnail = initdata["metadata"]["channelMetadataRenderer"]["avatar"]["thumbnails"][0]["url"].as_s