summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsyeopite <syeopite@syeopite.dev>2021-08-04 19:54:41 -0700
committersyeopite <syeopite@syeopite.dev>2021-09-24 21:07:07 -0700
commite5f07dedbf92459a237165f359d7565e638d4ffa (patch)
treeb8e5dae2da7e31886b409e41b645a06e29fee07c /src
parentca9eb0d5392743cd64c9e0c010ae9c507699bc7c (diff)
downloadinvidious-e5f07dedbf92459a237165f359d7565e638d4ffa.tar.gz
invidious-e5f07dedbf92459a237165f359d7565e638d4ffa.tar.bz2
invidious-e5f07dedbf92459a237165f359d7565e638d4ffa.zip
Typos and tiny styling changes
Diffstat (limited to 'src')
-rw-r--r--src/invidious/helpers/extractors.cr15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/invidious/helpers/extractors.cr b/src/invidious/helpers/extractors.cr
index dc46d40a..3a90f017 100644
--- a/src/invidious/helpers/extractors.cr
+++ b/src/invidious/helpers/extractors.cr
@@ -35,9 +35,7 @@ private module Parsers
title = extract_text(item_contents["title"]) || ""
# Extract author information
- author_info = item_contents["ownerText"]?.try &.["runs"]?.try &.as_a?.try &.[0]?
- if author_info = item_contents.dig?("ownerText", "runs")
- author_info = author_info[0]
+ if author_info = item_contents.dig?("ownerText", "runs", 0)
author = author_info["text"].as_s
author_id = HelperExtractors.get_browse_endpoint(author_info)
else
@@ -49,7 +47,7 @@ private module Parsers
# Instead, in its place is the amount of people currently watching. This behavior should be replicated
# on Invidious once all features of livestreams are supported. On an unrelated note, defaulting to the current
# time for publishing isn't a good idea.
- published = item_contents["publishedTimeText"]?.try &.["simpleText"].try { |t| decode_date(t.as_s) } || Time.local
+ published = item_contents.dig?("publishedTimeText", "simpleText").try { |t| decode_date(t.as_s) } || Time.local
# Typically views are stored under a "simpleText" in the "viewCountText". However, for
# livestreams and premiered it is stored under a "runs" array: [{"text":123}, {"text": "watching"}]
@@ -119,8 +117,10 @@ private module Parsers
author_thumbnail = HelperExtractors.get_thumbnails(item_contents)
# When public subscriber count is disabled, the subscriberCountText isn't sent by InnerTube.
+ # Always simpleText
# TODO change default value to nil
- subscriber_count = item_contents.dig?("subscriberCountText").try &.["simpleText"].try { |s| short_text_to_number(s.as_s.split(" ")[0]) } || 0
+ subscriber_count = item_contents.dig?("subscriberCountText").try &.["simpleText"].try { \
+ |s| short_text_to_number(s.as_s.split(" ")[0]) } || 0
auto_generated = !item_contents["videoCountText"]? ? true : false
@@ -420,10 +420,9 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil,
return result
end
end
- # TODO radioRenderer, showRenderer, shelfRenderer, horizontalCardListRenderer, searchPyvRenderer
end
-# Parses multiple items from Youtube's initial JSON response into a more usable structure.
+# 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) : Array(SearchItem)
@@ -436,7 +435,7 @@ def extract_items(initial_data : Hash(String, JSON::Any), author_fallback : Stri
unpackaged_data = initial_data
end
- # This is identicial to the parser cyling of extract_item().
+ # This is identical to the parser cyling of extract_item().
ITEM_CONTAINER_EXTRACTOR.each do |extractor|
results = extractor.process(unpackaged_data)
if !results.nil?