From dcf4330b3550f191a2e7025b58a52243127bcfcd Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 22 Jul 2018 12:15:18 -0500 Subject: [PATCH] Add 'commentCount' to '/comments/:id' --- src/invidious.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/invidious.cr b/src/invidious.cr index c47919763..f9f39d59c 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -530,6 +530,11 @@ get "/comments/:id" do |env| comments = JSON.build do |json| json.object do + if body["header"]? + comment_count = body["header"]["commentsHeaderRenderer"]["countText"]["simpleText"].as_s.rchop(" Comments").delete(',').to_i + json.field "commentCount", comment_count + end + json.field "comments" do json.array do contents.as_a.each do |item|