From bfb7f6a3096bbcccd555561047869344bfd8a43b Mon Sep 17 00:00:00 2001 From: wrvnnull Date: Mon, 17 Aug 2026 05:13:54 +0800 Subject: [PATCH] Fix broken channel link for related videos with multiple creators (#5722) parse_related_video only read runs[0] of the byline. Multi-creator videos expose several runs (e.g. 'Channel A', ' and', 'Channel B'), so creators past the first had no browseId and no channel link. Now iterate all runs and pick the first carrying a channel id; the displayed author text is unchanged (still runs[0].text). --- src/invidious/videos/parser.cr | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 8367fcd7..97488373 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -19,15 +19,28 @@ module Invidious::Videos::Parser decode_length_seconds(box.as_s).to_s end - # Both have "short", so the "long" option shouldn't be required - channel_info = (related["shortBylineText"]? || related["longBylineText"]?) - .try &.dig?("runs", 0) + # Both have "short", so the "long" option shouldn't be required. + # Videos with multiple creators expose each creator as a separate run + # inside "runs" (e.g. "Channel A", " and ", "Channel B"). The previous + # code only ever read runs[0], so any creator past the first one had no + # channel link. We now pick the first run that actually carries a + # channel id (browseId) so multi-creator videos still get a working link. + byline = (related["shortBylineText"]? || related["longBylineText"]?) + + author = byline.try { |b| b.dig?("runs", 0, "text") } + + ucid = byline.try do |b| + runs = b.dig?("runs") + next nil unless runs + runs.as_a.each do |run| + if id = HelperExtractors.get_browse_id(run) + break id + end + end + end - author = channel_info.try &.dig?("text") author_verified = has_verified_badge?(related["ownerBadges"]?).to_s - ucid = channel_info.try { |ci| HelperExtractors.get_browse_id(ci) } - short_view_count = related.try do |r| HelperExtractors.get_short_view_count(r).to_s end