mirror of
https://github.com/iv-org/invidious.git
synced 2026-08-17 05:20:51 -05:00
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).
This commit is contained in:
parent
d10f2a4802
commit
bfb7f6a309
@ -19,15 +19,28 @@ module Invidious::Videos::Parser
|
|||||||
decode_length_seconds(box.as_s).to_s
|
decode_length_seconds(box.as_s).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Both have "short", so the "long" option shouldn't be required
|
# Both have "short", so the "long" option shouldn't be required.
|
||||||
channel_info = (related["shortBylineText"]? || related["longBylineText"]?)
|
# Videos with multiple creators expose each creator as a separate run
|
||||||
.try &.dig?("runs", 0)
|
# 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
|
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|
|
short_view_count = related.try do |r|
|
||||||
HelperExtractors.get_short_view_count(r).to_s
|
HelperExtractors.get_short_view_count(r).to_s
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user