From 8261a28478dd5839f5f20d2453895092281d12cb Mon Sep 17 00:00:00 2001 From: NDilanka Date: Sat, 22 Aug 2026 10:06:45 +0530 Subject: [PATCH] fix(channels): fetch videos from redirected channel id, refresh premiere timestamps Addresses review feedback: follow ChannelRedirect through to the videos tab request while keeping the DB row under the originally requested ID, and update premiere_timestamp on conflict now that InnerTube provides it. --- src/invidious/channels/channels.cr | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/invidious/channels/channels.cr b/src/invidious/channels/channels.cr index af115e384..9024588ff 100644 --- a/src/invidious/channels/channels.cr +++ b/src/invidious/channels/channels.cr @@ -161,10 +161,14 @@ def fetch_channel(ucid, pull_all_videos : Bool) begin about_channel = get_about_info(ucid) + videos_ucid = ucid rescue ex : ChannelRedirect # Old-style UCIDs can be redirected to a new one by YouTube. The RSS - # endpoint used to follow those redirects transparently. + # endpoint used to follow those redirects transparently. Videos are + # fetched from the channel they actually live on, while the DB row + # keeps the originally requested ID to not break subscriptions. about_channel = get_about_info(ex.channel_id) + videos_ucid = ex.channel_id end LOGGER.trace("fetch_channel: #{ucid} : author = #{about_channel.author}, auto_generated = #{about_channel.auto_generated}") @@ -178,7 +182,7 @@ def fetch_channel(ucid, pull_all_videos : Bool) }) LOGGER.trace("fetch_channel: #{ucid} : Downloading channel videos page") - videos, continuation = IV::Channel::Tabs.get_videos(channel) + videos, continuation = IV::Channel::Tabs.get_videos(about_channel.author, videos_ucid) LOGGER.trace("fetch_channel: #{ucid} : Extracting videos from the channel videos tab") videos.select(SearchVideo).each do |video| @@ -197,7 +201,7 @@ def fetch_channel(ucid, pull_all_videos : Bool) LOGGER.trace("fetch_channel: #{ucid} : video #{video.id} : Updating or inserting video") - was_insert = Invidious::Database::ChannelVideos.insert(channel_video) + was_insert = Invidious::Database::ChannelVideos.insert(channel_video, with_premiere_timestamp: true) if was_insert LOGGER.trace("fetch_channel: #{ucid} : video #{video.id} : Inserted, updating subscriptions")