mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-17 10:08:30 +00:00
Add debug/trace logging to extract_items
This commit is contained in:
parent
347c189f3f
commit
163b3be0d5
@ -113,6 +113,10 @@ private module Parsers
|
|||||||
premiere_timestamp: premiere_timestamp,
|
premiere_timestamp: premiere_timestamp,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.parser_name
|
||||||
|
return {{@type.name}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parses a InnerTube channelRenderer into a SearchChannel. Returns nil when the given object isn't a channelRenderer
|
# Parses a InnerTube channelRenderer into a SearchChannel. Returns nil when the given object isn't a channelRenderer
|
||||||
@ -159,6 +163,10 @@ private module Parsers
|
|||||||
auto_generated: auto_generated,
|
auto_generated: auto_generated,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.parser_name
|
||||||
|
return {{@type.name}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parses a InnerTube gridPlaylistRenderer into a SearchPlaylist. Returns nil when the given object isn't a gridPlaylistRenderer
|
# Parses a InnerTube gridPlaylistRenderer into a SearchPlaylist. Returns nil when the given object isn't a gridPlaylistRenderer
|
||||||
@ -194,6 +202,10 @@ private module Parsers
|
|||||||
thumbnail: playlist_thumbnail,
|
thumbnail: playlist_thumbnail,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.parser_name
|
||||||
|
return {{@type.name}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parses a InnerTube playlistRenderer into a SearchPlaylist. Returns nil when the given object isn't a playlistRenderer
|
# Parses a InnerTube playlistRenderer into a SearchPlaylist. Returns nil when the given object isn't a playlistRenderer
|
||||||
@ -246,6 +258,10 @@ private module Parsers
|
|||||||
thumbnail: playlist_thumbnail,
|
thumbnail: playlist_thumbnail,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.parser_name
|
||||||
|
return {{@type.name}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parses a InnerTube shelfRenderer into a Category. Returns nil when the given object isn't a shelfRenderer
|
# Parses a InnerTube shelfRenderer into a Category. Returns nil when the given object isn't a shelfRenderer
|
||||||
@ -307,6 +323,10 @@ private module Parsers
|
|||||||
badges: badges,
|
badges: badges,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.parser_name
|
||||||
|
return {{@type.name}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -372,6 +392,10 @@ private module Extractors
|
|||||||
|
|
||||||
return raw_items
|
return raw_items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.extractor_name
|
||||||
|
return {{@type.name}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Extracts items from the InnerTube response for search results
|
# Extracts items from the InnerTube response for search results
|
||||||
@ -409,6 +433,10 @@ private module Extractors
|
|||||||
|
|
||||||
return raw_items.flatten
|
return raw_items.flatten
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.extractor_name
|
||||||
|
return {{@type.name}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Extracts continuation items from a InnerTube response
|
# Extracts continuation items from a InnerTube response
|
||||||
@ -440,6 +468,10 @@ private module Extractors
|
|||||||
|
|
||||||
return raw_items
|
return raw_items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.extractor_name
|
||||||
|
return {{@type.name}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -529,8 +561,14 @@ def extract_item(item : JSON::Any, author_fallback : String? = "",
|
|||||||
# Each parser automatically validates the data given to see if the data is
|
# Each parser automatically validates the data given to see if the data is
|
||||||
# applicable to itself. If not nil is returned and the next parser is attemped.
|
# applicable to itself. If not nil is returned and the next parser is attemped.
|
||||||
ITEM_PARSERS.each do |parser|
|
ITEM_PARSERS.each do |parser|
|
||||||
|
LOGGER.trace("extract_item: Attempting to parse item using \"#{parser.parser_name}\" (cycling...)")
|
||||||
|
|
||||||
if result = parser.process(item, author_fallback)
|
if result = parser.process(item, author_fallback)
|
||||||
|
LOGGER.debug("extract_item: Successfully parsed via #{parser.parser_name}")
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
else
|
||||||
|
LOGGER.trace("extract_item: Parser: \"#{parser.parser_name}\" does not apply. Cycling to the next one...")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -550,7 +588,10 @@ def extract_items(initial_data : Hash(String, JSON::Any), author_fallback : Stri
|
|||||||
|
|
||||||
# This is identical to the parser cycling of extract_item().
|
# This is identical to the parser cycling of extract_item().
|
||||||
ITEM_CONTAINER_EXTRACTOR.each do |extractor|
|
ITEM_CONTAINER_EXTRACTOR.each do |extractor|
|
||||||
|
LOGGER.trace("extract_items: Attempting to extract item container using \"#{extractor.extractor_name}\" (cycling...)")
|
||||||
|
|
||||||
if container = extractor.process(unpackaged_data)
|
if container = extractor.process(unpackaged_data)
|
||||||
|
LOGGER.debug("extract_items: Successfully unpacked container with \"#{extractor.extractor_name}\"")
|
||||||
# Extract items in container
|
# Extract items in container
|
||||||
container.each do |item|
|
container.each do |item|
|
||||||
if parsed_result = extract_item(item, author_fallback, author_id_fallback)
|
if parsed_result = extract_item(item, author_fallback, author_id_fallback)
|
||||||
@ -559,6 +600,8 @@ def extract_items(initial_data : Hash(String, JSON::Any), author_fallback : Stri
|
|||||||
end
|
end
|
||||||
|
|
||||||
break
|
break
|
||||||
|
else
|
||||||
|
LOGGER.trace("extract_items: Extractor: \"#{extractor.extractor_name}\" does not apply. Cycling to the next one...")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user