mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
Fix for the ArithmeticOverflow Problem
This commit is contained in:
parent
865704dc7b
commit
85dd3533bb
2 changed files with 6 additions and 1 deletions
|
@ -162,7 +162,7 @@ def number_with_separator(number)
|
|||
end
|
||||
|
||||
def short_text_to_number(short_text : String) : Int64
|
||||
matches = /(?<number>\d+(\.\d+)?)\s?(?<suffix>[mMkKbB])?/.match(short_text)
|
||||
matches = /(?<number>\d+(\.\d+)?)\s?(?<suffix>[mMkKbB]|())?/.match(short_text)
|
||||
number = matches.try &.["number"].to_f || 0.0
|
||||
|
||||
case matches.try &.["suffix"].downcase
|
||||
|
|
|
@ -169,7 +169,12 @@ private module Parsers
|
|||
# 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", "simpleText")
|
||||
if !subscriber_count || !subscriber_count.as_s.includes? " subscriber"
|
||||
subscriber_count = item_contents.dig?("videoCountText", "simpleText")
|
||||
end
|
||||
subscriber_count = subscriber_count
|
||||
.try { |s| short_text_to_number(s.as_s.split(" ")[0]).to_i32 } || 0
|
||||
|
||||
# Auto-generated channels doesn't have videoCountText
|
||||
|
|
Loading…
Reference in a new issue