We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e6ddd6d commit 9621175Copy full SHA for 9621175
src/invidious/yt_backend/extractors.cr
@@ -519,6 +519,20 @@ module HelperExtractors
519
end
520
521
522
+ # Retrieves the amount of views/viewers a video has.
523
+ # Seems to be used on related videos only
524
+ #
525
+ # Returns "0" when unable to parse
526
+ def self.get_short_view_count(container : JSON::Any) : String
527
+ box = container["shortViewCountText"]?
528
+ return "0" if !box
529
+
530
+ # Simpletext: "4M views"
531
+ # runs: {"text": "1.1K"},{"text":" watching"}
532
+ return box["simpleText"]?.try &.as_s.sub(" views", "") ||
533
+ box.dig?("runs", 0, "text").try &.as_s || "0"
534
+ end
535
536
# Retrieve lowest quality thumbnail from InnerTube data
537
#
538
# TODO allow configuration of image quality (-1 is highest)
0 commit comments