Invidious is an alternative front-end to YouTube
Fix templating for videos with 0 comments
Omar Rothb9e2fee2c9af
diff --git a/src/invidious.cr b/src/invidious.crindex c7de22fb..f267d7c1 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -2041,26 +2041,7 @@ get "/api/v1/comments/:id" do |env|halt env, status_code: 500, response: error_messageend- if format == "json"- next comments- else- comments = JSON.parse(comments)- content_html = template_youtube_comments(comments)-- response = JSON.build do |json|- json.object do- json.field "contentHtml", content_html-- if comments["commentCount"]?- json.field "commentCount", comments["commentCount"]- else- json.field "commentCount", 0- end- end- end-- next response- end+ next commentselsif source == "reddit"begincomments, reddit_thread = fetch_reddit_comments(id)diff --git a/src/invidious/comments.cr b/src/invidious/comments.crindex a699aaac..ba5d6f08 100644--- a/src/invidious/comments.cr+++ b/src/invidious/comments.cr@@ -264,6 +264,23 @@ def fetch_youtube_comments(id, continuation, proxies, format)endend+ if format == "html"+ comments = JSON.parse(comments)+ content_html = template_youtube_comments(comments)++ comments = JSON.build do |json|+ json.object do+ json.field "contentHtml", content_html++ if comments["commentCount"]?+ json.field "commentCount", comments["commentCount"]+ else+ json.field "commentCount", 0+ end+ end+ end+ end+return commentsend