extractors: Add support for richGridRenderer
This commit is contained in:
parent
84cd4d6a5b
commit
f267394bbe
|
@ -436,21 +436,31 @@ private module Extractors
|
||||||
content = extract_selected_tab(target["tabs"])["content"]
|
content = extract_selected_tab(target["tabs"])["content"]
|
||||||
|
|
||||||
if section_list_contents = content.dig?("sectionListRenderer", "contents")
|
if section_list_contents = content.dig?("sectionListRenderer", "contents")
|
||||||
section_list_contents.as_a.each do |renderer_container|
|
raw_items = unpack_section_list(section_list_contents)
|
||||||
renderer_container_contents = renderer_container["itemSectionRenderer"]["contents"][0]
|
elsif rich_grid_contents = content.dig?("richGridRenderer", "contents")
|
||||||
|
raw_items = rich_grid_contents.as_a
|
||||||
|
end
|
||||||
|
|
||||||
# Category extraction
|
return raw_items
|
||||||
if items_container = renderer_container_contents["shelfRenderer"]?
|
end
|
||||||
raw_items << renderer_container_contents
|
|
||||||
next
|
|
||||||
elsif items_container = renderer_container_contents["gridRenderer"]?
|
|
||||||
else
|
|
||||||
items_container = renderer_container_contents
|
|
||||||
end
|
|
||||||
|
|
||||||
items_container["items"]?.try &.as_a.each do |item|
|
private def self.unpack_section_list(contents)
|
||||||
raw_items << item
|
raw_items = [] of JSON::Any
|
||||||
end
|
|
||||||
|
contents.as_a.each do |renderer_container|
|
||||||
|
renderer_container_contents = renderer_container["itemSectionRenderer"]["contents"][0]
|
||||||
|
|
||||||
|
# Category extraction
|
||||||
|
if items_container = renderer_container_contents["shelfRenderer"]?
|
||||||
|
raw_items << renderer_container_contents
|
||||||
|
next
|
||||||
|
elsif items_container = renderer_container_contents["gridRenderer"]?
|
||||||
|
else
|
||||||
|
items_container = renderer_container_contents
|
||||||
|
end
|
||||||
|
|
||||||
|
items_container["items"]?.try &.as_a.each do |item|
|
||||||
|
raw_items << item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -525,14 +535,11 @@ private module Extractors
|
||||||
end
|
end
|
||||||
|
|
||||||
private def self.extract(target)
|
private def self.extract(target)
|
||||||
raw_items = [] of JSON::Any
|
content = target["continuationItems"]?
|
||||||
if content = target["gridContinuation"]?
|
content ||= target.dig?("gridContinuation", "items")
|
||||||
raw_items = content["items"].as_a
|
content ||= target.dig?("richGridContinuation", "contents")
|
||||||
elsif content = target["continuationItems"]?
|
|
||||||
raw_items = content.as_a
|
|
||||||
end
|
|
||||||
|
|
||||||
return raw_items
|
return content.nil? ? [] of JSON::Any : content.as_a
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.extractor_name
|
def self.extractor_name
|
||||||
|
|
Loading…
Reference in a new issue