Invidious is an alternative front-end to YouTube
Switch to structs in extractors.cr for performance
syeopite3dea670091b0
diff --git a/src/invidious/helpers/extractors.cr b/src/invidious/helpers/extractors.crindex e8226888..68e84850 100644--- a/src/invidious/helpers/extractors.cr+++ b/src/invidious/helpers/extractors.cr@@ -27,7 +27,7 @@ end# They're accessed through the process() method which validates the given data as applicable# to their specific struct and then use the internal parse() method to assemble the struct# specific to their category.-private class ItemParser+private abstract struct ItemParser# Base type for all item parsers.def process(item : JSON::Any, author_fallback : AuthorFallback)end@@ -36,7 +36,7 @@ private class ItemParserendend-private class VideoParser < ItemParser+private struct VideoParser < ItemParserdef process(item, author_fallback)if item_contents = (item["videoRenderer"]? || item["gridVideoRenderer"]?)return self.parse(item_contents, author_fallback)@@ -94,7 +94,7 @@ private class VideoParser < ItemParserendend-private class ChannelParser < ItemParser+private struct ChannelParser < ItemParserdef process(item, author_fallback)if item_contents = (item["channelRenderer"]? || item["gridChannelRenderer"]?)return self.parse(item_contents, author_fallback)@@ -125,7 +125,7 @@ private class ChannelParser < ItemParserendend-private class GridPlaylistParser < ItemParser+private struct GridPlaylistParser < ItemParserdef process(item, author_fallback)if item_contents = item["gridPlaylistRenderer"]?return self.parse(item_contents, author_fallback)@@ -151,7 +151,7 @@ private class GridPlaylistParser < ItemParserendend-private class PlaylistParser < ItemParser+private struct PlaylistParser < ItemParserdef process(item, author_fallback)if item_contents = item["playlistRenderer"]?return self.parse(item_contents, author_fallback)@@ -195,7 +195,7 @@ private class PlaylistParser < ItemParserendend-private class CategoryParser < ItemParser+private struct CategoryParser < ItemParserdef process(item, author_fallback)if item_contents = item["shelfRenderer"]?return self.parse(item_contents, author_fallback)@@ -262,7 +262,7 @@ end# a structure we can more easily use via the parsers above. Their internals are# identical to the item parsers.-private class ItemsContainerExtractor+private abstract struct ItemsContainerExtractordef process(item : Hash(String, JSON::Any))end@@ -270,7 +270,7 @@ private class ItemsContainerExtractorendend-private class YoutubeTabsExtractor < ItemsContainerExtractor+private struct YoutubeTabsExtractor < ItemsContainerExtractordef process(initial_data)if target = initial_data["twoColumnBrowseResultsRenderer"]?self.extract(target)@@ -304,7 +304,7 @@ private class YoutubeTabsExtractor < ItemsContainerExtractorendend-private class SearchResultsExtractor < ItemsContainerExtractor+private struct SearchResultsExtractor < ItemsContainerExtractordef process(initial_data)if target = initial_data["twoColumnSearchResultsRenderer"]?self.extract(target)@@ -326,7 +326,7 @@ private class SearchResultsExtractor < ItemsContainerExtractorendend-private class ContinuationExtractor < ItemsContainerExtractor+private struct ContinuationExtractor < ItemsContainerExtractordef process(initial_data)if target = initial_data["continuationContents"]?self.extract(target)