summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2023-04-01 18:51:32 +0200
committerSamantaz Fox <coding@samantaz.fr>2023-04-01 18:51:32 +0200
commit8db2a93827a4e27a55a9095be15083ea68cdd571 (patch)
tree90ad7709dd26330ae1c5b015de24c16efb0d2d84 /src
parentc0eab2b1f61f13b7f70368cee0ae0efb1034f39e (diff)
parent3492485789ae3758f551916b406ed75b3c028021 (diff)
downloadinvidious-8db2a93827a4e27a55a9095be15083ea68cdd571.tar.gz
invidious-8db2a93827a4e27a55a9095be15083ea68cdd571.tar.bz2
invidious-8db2a93827a4e27a55a9095be15083ea68cdd571.zip
Search: Fix channel search (#3699)
Diffstat (limited to 'src')
-rw-r--r--src/invidious/yt_backend/extractors.cr25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr
index 978e380d..1a37d606 100644
--- a/src/invidious/yt_backend/extractors.cr
+++ b/src/invidious/yt_backend/extractors.cr
@@ -18,6 +18,7 @@ private ITEM_PARSERS = {
Parsers::CategoryRendererParser,
Parsers::RichItemRendererParser,
Parsers::ReelItemRendererParser,
+ Parsers::ItemSectionRendererParser,
Parsers::ContinuationItemRendererParser,
}
@@ -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
#