Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search: Fix channel search #3699

Merged
merged 1 commit into from
Apr 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/invidious/yt_backend/extractors.cr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ private ITEM_PARSERS = {
Parsers::CategoryRendererParser,
Parsers::RichItemRendererParser,
Parsers::ReelItemRendererParser,
Parsers::ItemSectionRendererParser,
Parsers::ContinuationItemRendererParser,
}

Expand Down Expand Up @@ -377,6 +378,30 @@ private module Parsers
end
end

# Parses an InnerTube itemSectionRenderer into a SearchVideo.
# Returns nil when the given object isn't a ItemSectionRenderer
#
# A itemSectionRenderer seems to be a simple wrapper for a videoRenderer, used
# by the result page for channel searches. It is located inside a continuationItems
# container.It is very similar to RichItemRendererParser
#
module ItemSectionRendererParser
def self.process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item.dig?("itemSectionRenderer", "contents", 0)
return self.parse(item_contents, author_fallback)
end
end

private def self.parse(item_contents, author_fallback)
child = VideoRendererParser.process(item_contents, author_fallback)
return child
end

def self.parser_name
return {{@type.name}}
end
end

# Parses an InnerTube richItemRenderer into a SearchVideo.
# Returns nil when the given object isn't a RichItemRenderer
#
Expand Down