From 1e33c0c288f05818beb2c7f483b40c583350e577 Mon Sep 17 00:00:00 2001 From: bopol Date: Sun, 21 Feb 2021 00:08:52 +0100 Subject: [PATCH] Fix comment replies count --- src/invidious/comments.cr | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index a8bbf74b..13ebbd73 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -195,8 +195,14 @@ def fetch_youtube_comments(id, db, cursor, format, locale, thin_mode, region, so end if node_replies && !response["commentRepliesContinuation"]? - reply_count = (node_replies["moreText"]["simpleText"]? || node_replies["moreText"]["runs"]?.try &.[0]?.try &.["text"]?) - .try &.as_s.gsub(/\D/, "").to_i? || 1 + if node_replies["moreText"]? + reply_count = (node_replies["moreText"]["simpleText"]? || node_replies["moreText"]["runs"]?.try &.[0]?.try &.["text"]?) + .try &.as_s.gsub(/\D/, "").to_i? || 1 + elsif node_replies["viewReplies"]? + reply_count = node_replies["viewReplies"]["buttonRenderer"]["text"]?.try &.["runs"][1]?.try &.["text"]?.try &.as_s.to_i? || 1 + else + reply_count = 1 + end continuation = node_replies["continuations"]?.try &.as_a[0]["nextContinuationData"]["continuation"].as_s continuation ||= ""