From 45ce301bd29c0efda0c8f7c05a36765c5be187ff Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Wed, 15 Aug 2018 11:47:37 -0500 Subject: [PATCH] Fix reply count extraction --- src/invidious.cr | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index decd10bb..97424c81 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1785,9 +1785,13 @@ get "/api/v1/comments/:id" do |env| json.field "commentId", node_comment["commentId"] if node_replies && !response["commentRepliesContinuation"]? - reply_count = node_replies["moreText"]["simpleText"].as_s.match(/View all (?\d+) replies/) - .try &.["count"].to_i? + reply_count = node_replies["moreText"]["simpleText"].as_s.delete("View all reply replies,") + if reply_count.empty? + reply_count = 1 + else + reply_count = reply_count.try &.to_i? reply_count ||= 1 + end continuation = node_replies["continuations"].as_a[0]["nextContinuationData"]["continuation"].as_s