diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 2b1b9cc75..7f2514342 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -274,56 +274,55 @@ def fetch_reddit_comments(id, sort_by = "confidence") end def template_youtube_comments(comments, locale, thin_mode) - html = "" - - root = comments["comments"].as_a - root.each do |child| - if child["replies"]? - replies_html = <<-END_HTML -
- #{translate(locale, "View `x` replies", child["replies"]["replyCount"].to_s)} -
+ String.build do |html| + root = comments["comments"].as_a + root.each do |child| + if child["replies"]? + replies_html = <<-END_HTML + -- - #{child["author"]} - -
#{child["contentHtml"]}
- #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""} - | - [YT] - | - #{number_with_separator(child["likeCount"])} - END_HTML - - if child["creatorHeart"]? - if !thin_mode - creator_thumbnail = "/ggpht#{URI.parse(child["creatorHeart"]["creatorThumbnail"].as_s).full_path}" - else - creator_thumbnail = "" + END_HTML end - html += <<-END_HTML + if !thin_mode + author_thumbnail = "/ggpht#{URI.parse(child["authorThumbnails"][-1]["url"].as_s).full_path}" + else + author_thumbnail = "" + end + + html << <<-END_HTML ++ + #{child["author"]} + +
#{child["contentHtml"]}
+ #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""} + | + [YT] + | + #{number_with_separator(child["likeCount"])} + END_HTML + + if child["creatorHeart"]? + if !thin_mode + creator_thumbnail = "/ggpht#{URI.parse(child["creatorHeart"]["creatorThumbnail"].as_s).full_path}" + else + creator_thumbnail = "" + end + + html << <<-END_HTML- [ - ] - #{child.author} - #{translate(locale, "`x` points", number_with_separator(child.score))} - #{translate(locale, "`x` ago", recode_date(child.created_utc, locale))} - #{translate(locale, "permalink")} -
-+ [ - ] + #{child.author} + #{translate(locale, "`x` points", number_with_separator(child.score))} + #{translate(locale, "`x` ago", recode_date(child.created_utc, locale))} + #{translate(locale, "permalink")} +
+