mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-19 04:34:23 -05:00
Apply suggestions from code review
Co-authored-by: Samantaz Fox <coding@samantaz.fr>
This commit is contained in:
parent
092b8a4e52
commit
6df85718e6
@ -139,8 +139,8 @@ private module Parsers
|
|||||||
# When public subscriber count is disabled, the subscriberCountText isn't sent by InnerTube.
|
# When public subscriber count is disabled, the subscriberCountText isn't sent by InnerTube.
|
||||||
# Always simpleText
|
# Always simpleText
|
||||||
# TODO change default value to nil
|
# TODO change default value to nil
|
||||||
subscriber_count = item_contents.dig?("subscriberCountText").try &.["simpleText"].try { \
|
subscriber_count = item_contents.dig?("subscriberCountText", "simpleText")
|
||||||
|s| short_text_to_number(s.as_s.split(" ")[0]) } || 0
|
.try { |s| short_text_to_number(s.as_s.split(" ")[0]) } || 0
|
||||||
|
|
||||||
auto_generated = !item_contents["videoCountText"]? ? true : false
|
auto_generated = !item_contents["videoCountText"]? ? true : false
|
||||||
|
|
||||||
@ -265,7 +265,8 @@ private module Parsers
|
|||||||
|
|
||||||
private def self.parse(item_contents, author_fallback)
|
private def self.parse(item_contents, author_fallback)
|
||||||
title = extract_text(item_contents["title"]?) || ""
|
title = extract_text(item_contents["title"]?) || ""
|
||||||
url = item_contents["endpoint"]?.try &.dig("commandMetadata", "webCommandMetadata", "url").as_s
|
url = item_contents.dig?("endpoint", "commandMetadata", "webCommandMetadata", "url")
|
||||||
|
.try &.as_s
|
||||||
|
|
||||||
# Sometimes a category can have badges.
|
# Sometimes a category can have badges.
|
||||||
badges = [] of Tuple(String, String) # (Badge style, label)
|
badges = [] of Tuple(String, String) # (Badge style, label)
|
||||||
@ -450,7 +451,7 @@ private module HelperExtractors
|
|||||||
# Returns a 0 when it's unable to do so
|
# Returns a 0 when it's unable to do so
|
||||||
def self.get_video_count(container : JSON::Any) : Int32
|
def self.get_video_count(container : JSON::Any) : Int32
|
||||||
if box = container["videoCountText"]?
|
if box = container["videoCountText"]?
|
||||||
return extract_text(container["videoCountText"]?).try &.gsub(/\D/, "").to_i || 0
|
return extract_text(box).try &.gsub(/\D/, "").to_i || 0
|
||||||
elsif box = container["videoCount"]?
|
elsif box = container["videoCount"]?
|
||||||
return box.as_s.to_i
|
return box.as_s.to_i
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user