mirror of
https://github.com/iv-org/invidious.git
synced 2026-09-06 00:52:45 -05:00
fix(parser): link collaborative related videos
This commit is contained in:
parent
9d1291a0b8
commit
acbe994989
41
spec/invidious/videos/related_video_parser_spec.cr
Normal file
41
spec/invidious/videos/related_video_parser_spec.cr
Normal file
@ -0,0 +1,41 @@
|
||||
require "../../parsers_helper.cr"
|
||||
|
||||
Spectator.describe Invidious::Videos::Parser do
|
||||
it "uses the primary owner channel for collaborative related videos" do
|
||||
related = JSON.parse(<<-JSON)
|
||||
{
|
||||
"videoId": "b2_vBMQmi3M",
|
||||
"title": {"simpleText": "Collaborative video"},
|
||||
"shortBylineText": {
|
||||
"runs": [
|
||||
{
|
||||
"text": "D/V and FΛDE",
|
||||
"navigationEndpoint": {
|
||||
"showDialogCommand": {
|
||||
"panelLoadingStrategy": {
|
||||
"inlineContent": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"channelThumbnailSupportedRenderers": {
|
||||
"channelThumbnailWithLinkRenderer": {
|
||||
"navigationEndpoint": {
|
||||
"browseEndpoint": {
|
||||
"browseId": "UClr4yKwH072yt1nUX29dQGg",
|
||||
"canonicalBaseUrl": "/@DslashV"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
result = Invidious::Videos::Parser.parse_related_video(related).not_nil!
|
||||
|
||||
expect(result["author"].as_s).to eq("D/V and FΛDE")
|
||||
expect(result["ucid"].as_s).to eq("UClr4yKwH072yt1nUX29dQGg")
|
||||
end
|
||||
end
|
||||
@ -27,6 +27,13 @@ module Invidious::Videos::Parser
|
||||
author_verified = has_verified_badge?(related["ownerBadges"]?).to_s
|
||||
|
||||
ucid = channel_info.try { |ci| HelperExtractors.get_browse_id(ci) }
|
||||
if ucid.nil? || ucid.empty?
|
||||
channel_renderer = related.dig?(
|
||||
"channelThumbnailSupportedRenderers",
|
||||
"channelThumbnailWithLinkRenderer"
|
||||
)
|
||||
ucid = channel_renderer.try { |renderer| HelperExtractors.get_browse_id(renderer) }
|
||||
end
|
||||
|
||||
short_view_count = related.try do |r|
|
||||
HelperExtractors.get_short_view_count(r).to_s
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user