mirror of
https://github.com/iv-org/invidious.git
synced 2026-09-07 09:33:04 -05:00
Fix collaboration channel links
This commit is contained in:
parent
9d1291a0b8
commit
29eb23efb6
51
spec/invidious/videos/related_videos_extract_spec.cr
Normal file
51
spec/invidious/videos/related_videos_extract_spec.cr
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
require "../../parsers_helper.cr"
|
||||||
|
|
||||||
|
Spectator.describe "parse_related_video" do
|
||||||
|
it "extracts the primary channel from collaboration bylines" do
|
||||||
|
related = JSON.parse(<<-JSON)
|
||||||
|
{
|
||||||
|
"videoId": "b2_vBMQmi3M",
|
||||||
|
"title": { "simpleText": "Alpha Beta Gamma" },
|
||||||
|
"shortBylineText": {
|
||||||
|
"runs": [{
|
||||||
|
"text": "Primary and Collaborator",
|
||||||
|
"navigationEndpoint": {
|
||||||
|
"showDialogCommand": {
|
||||||
|
"panelLoadingStrategy": {
|
||||||
|
"inlineContent": {
|
||||||
|
"dialogViewModel": {
|
||||||
|
"customContent": {
|
||||||
|
"listViewModel": {
|
||||||
|
"listItems": [{
|
||||||
|
"listItemViewModel": {
|
||||||
|
"rendererContext": {
|
||||||
|
"commandContext": {
|
||||||
|
"onTap": {
|
||||||
|
"innertubeCommand": {
|
||||||
|
"browseEndpoint": {
|
||||||
|
"browseId": "UClr4yKwH072yt1nUX29dQGg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JSON
|
||||||
|
|
||||||
|
parsed = Invidious::Videos::Parser.parse_related_video(related).not_nil!
|
||||||
|
|
||||||
|
expect(parsed["author"]).to eq("Primary and Collaborator")
|
||||||
|
expect(parsed["ucid"]).to eq("UClr4yKwH072yt1nUX29dQGg")
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -1141,7 +1141,13 @@ module HelperExtractors
|
|||||||
# Retrieves the ID required for querying the InnerTube browse endpoint.
|
# Retrieves the ID required for querying the InnerTube browse endpoint.
|
||||||
# Returns an empty string when it's unable to do so
|
# Returns an empty string when it's unable to do so
|
||||||
def self.get_browse_id(container)
|
def self.get_browse_id(container)
|
||||||
return container.dig?("navigationEndpoint", "browseEndpoint", "browseId").try &.as_s || ""
|
return container.dig?("navigationEndpoint", "browseEndpoint", "browseId").try &.as_s ||
|
||||||
|
container.dig?(
|
||||||
|
"navigationEndpoint", "showDialogCommand", "panelLoadingStrategy",
|
||||||
|
"inlineContent", "dialogViewModel", "customContent", "listViewModel",
|
||||||
|
"listItems", 0, "listItemViewModel", "rendererContext", "commandContext",
|
||||||
|
"onTap", "innertubeCommand", "browseEndpoint", "browseId"
|
||||||
|
).try &.as_s || ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user