diff options
| author | syeopite <syeopite@syeopite.dev> | 2021-06-29 09:23:48 -0700 |
|---|---|---|
| committer | syeopite <syeopite@syeopite.dev> | 2021-09-24 21:07:07 -0700 |
| commit | 8435e7991337edcb007b82c148a372a0a678b5c1 (patch) | |
| tree | d567e52518eb88e2bd870a72012de8e60159cd0d /src | |
| parent | 30e85b40f9b817c8620ef9536ad2d327da9ba83b (diff) | |
| download | invidious-8435e7991337edcb007b82c148a372a0a678b5c1.tar.gz invidious-8435e7991337edcb007b82c148a372a0a678b5c1.tar.bz2 invidious-8435e7991337edcb007b82c148a372a0a678b5c1.zip | |
Improve documentation for extract_item(s) funcs
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/helpers/extractors.cr | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/invidious/helpers/extractors.cr b/src/invidious/helpers/extractors.cr index c1f7205c..e8226888 100644 --- a/src/invidious/helpers/extractors.cr +++ b/src/invidious/helpers/extractors.cr @@ -347,10 +347,10 @@ private class ContinuationExtractor < ItemsContainerExtractor end end +# Parses an item from Youtube's JSON response into a more usable structure. +# The end result can either be a SearchVideo, SearchPlaylist or SearchChannel. def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fallback : String? = nil) - # Parses an item from Youtube's JSON response into a more usable structure. - # The end result can either be a SearchVideo, SearchPlaylist or SearchChannel. author_fallback = AuthorFallback.new(author_fallback, author_id_fallback) # Cycles through all of the item parsers and attempt to parse the raw YT JSON data. @@ -365,8 +365,10 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, # TODO radioRenderer, showRenderer, shelfRenderer, horizontalCardListRenderer, searchPyvRenderer end +# Parses multiple items from Youtube's initial JSON response into a more usable structure. +# The end result is an array of SearchItem. def extract_items(initial_data : Hash(String, JSON::Any), author_fallback : String? = nil, - author_id_fallback : String? = nil) + author_id_fallback : String? = nil) : Array(SearchItem) items = [] of SearchItem if unpackaged_data = initial_data["contents"]?.try &.as_h |
