|
|
@ -519,6 +519,20 @@ module HelperExtractors
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Retrieves the amount of views/viewers a video has.
|
|
|
|
|
|
|
|
# Seems to be used on related videos only
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Returns "0" when unable to parse
|
|
|
|
|
|
|
|
def self.get_short_view_count(container : JSON::Any) : String
|
|
|
|
|
|
|
|
box = container["shortViewCountText"]?
|
|
|
|
|
|
|
|
return "0" if !box
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Simpletext: "4M views"
|
|
|
|
|
|
|
|
# runs: {"text": "1.1K"},{"text":" watching"}
|
|
|
|
|
|
|
|
return box["simpleText"]?.try &.as_s.sub(" views", "") ||
|
|
|
|
|
|
|
|
box.dig?("runs", 0, "text").try &.as_s || "0"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Retrieve lowest quality thumbnail from InnerTube data
|
|
|
|
# Retrieve lowest quality thumbnail from InnerTube data
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# TODO allow configuration of image quality (-1 is highest)
|
|
|
|
# TODO allow configuration of image quality (-1 is highest)
|
|
|
|