Invidious is an alternative front-end to YouTube
Fix comment extractor
Omar Rotha9e86cecf5dc
diff --git a/src/invidious/comments.cr b/src/invidious/comments.crindex 7f1b010d..51c092ac 100644--- a/src/invidious/comments.cr+++ b/src/invidious/comments.cr@@ -114,7 +114,8 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_mcomments = JSON.build do |json|json.object doif body["header"]?- comment_count = body["header"]["commentsHeaderRenderer"]["countText"]["simpleText"].as_s.delete("Comments,").to_i+ comment_count = body["header"]["commentsHeaderRenderer"]["countText"]["runs"][0]?+ .try &.["text"].as_s.gsub(/\D/, "").to_i? || 0json.field "commentCount", comment_countend@@ -140,9 +141,7 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_mcontent_html = node_comment["contentText"]["simpleText"]?.try &.as_s.rchop('\ufeff').try { |block| HTML.escape(block) }.to_s ||content_to_comment_html(node_comment["contentText"]["runs"].as_a).try &.to_s || ""-- author = node_comment["authorText"]?.try &.["simpleText"]- author ||= ""+ author = node_comment["authorText"]?.try &.["simpleText"]? || ""json.field "author", authorjson.field "authorThumbnails" do@@ -193,13 +192,7 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_mendif node_replies && !response["commentRepliesContinuation"]?- 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+ reply_count = node_replies["moreText"]["runs"][0]?.try &.["text"].as_s.gsub(/\D/, "").to_i? || 1continuation = node_replies["continuations"]?.try &.as_a[0]["nextContinuationData"]["continuation"].as_scontinuation ||= ""