|
|
@ -18,6 +18,7 @@ private ITEM_PARSERS = {
|
|
|
|
Parsers::CategoryRendererParser,
|
|
|
|
Parsers::CategoryRendererParser,
|
|
|
|
Parsers::RichItemRendererParser,
|
|
|
|
Parsers::RichItemRendererParser,
|
|
|
|
Parsers::ReelItemRendererParser,
|
|
|
|
Parsers::ReelItemRendererParser,
|
|
|
|
|
|
|
|
Parsers::ItemSectionRendererParser,
|
|
|
|
Parsers::ContinuationItemRendererParser,
|
|
|
|
Parsers::ContinuationItemRendererParser,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -377,6 +378,30 @@ private module Parsers
|
|
|
|
end
|
|
|
|
end
|
|
|
|
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.
|
|
|
|
# Parses an InnerTube richItemRenderer into a SearchVideo.
|
|
|
|
# Returns nil when the given object isn't a RichItemRenderer
|
|
|
|
# Returns nil when the given object isn't a RichItemRenderer
|
|
|
|
#
|
|
|
|
#
|
|
|
@ -772,6 +797,7 @@ end
|
|
|
|
def extract_items(initial_data : InitialData, &block)
|
|
|
|
def extract_items(initial_data : InitialData, &block)
|
|
|
|
if unpackaged_data = initial_data["contents"]?.try &.as_h
|
|
|
|
if unpackaged_data = initial_data["contents"]?.try &.as_h
|
|
|
|
elsif unpackaged_data = initial_data["response"]?.try &.as_h
|
|
|
|
elsif unpackaged_data = initial_data["response"]?.try &.as_h
|
|
|
|
|
|
|
|
elsif unpackaged_data = initial_data.dig?("onResponseReceivedActions", 1).try &.as_h
|
|
|
|
elsif unpackaged_data = initial_data.dig?("onResponseReceivedActions", 0).try &.as_h
|
|
|
|
elsif unpackaged_data = initial_data.dig?("onResponseReceivedActions", 0).try &.as_h
|
|
|
|
else
|
|
|
|
else
|
|
|
|
unpackaged_data = initial_data
|
|
|
|
unpackaged_data = initial_data
|
|
|
|