From 76ad4e802603f82fe45d522a9c268e972d428a75 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Thu, 16 Feb 2023 14:12:56 -0500 Subject: [PATCH] show member icon, hide deleted emojis, fix non-custom emojis --- locales/en-US.json | 1 + src/invidious/comments.cr | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/locales/en-US.json b/locales/en-US.json index a5c16fd70..5bbf6db65 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -405,6 +405,7 @@ "YouTube comment permalink": "YouTube comment permalink", "permalink": "permalink", "`x` marked it with a ❤": "`x` marked it with a ❤", + "Member": "Member", "Audio mode": "Audio mode", "Video mode": "Video mode", "Playlists": "Playlists", diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 5749248eb..f1942ceb2 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -328,11 +328,21 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false) end author_name = HTML.escape(child["author"].as_s) + member_icon = "" if child["verified"]?.try &.as_bool && child["authorIsChannelOwner"]?.try &.as_bool author_name += " " elsif child["verified"]?.try &.as_bool author_name += " " end + if child["isMember"]?.try &.as_bool + member_icon = "\"\"" + end html << <<-END_HTML
@@ -343,6 +353,7 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false) #{author_name} + #{member_icon}

#{child["contentHtml"]}

END_HTML @@ -678,13 +689,17 @@ def content_to_comment_html(content, video_id : String? = "") text = "#{text}" if run["bold"]? text = "#{text}" if run["strikethrough"]? text = "#{text}" if run["italics"]? - if emojiImage = run.dig?("emoji", "image") - emojiAlt = emojiImage.dig?("accessibility", "accessibilityData", "label").try &.as_s || text - emojiThumb = emojiImage["thumbnails"][0] - emojiUrl = "/ggpht#{URI.parse(emojiThumb["url"].as_s).request_target}" - emojiWidth = emojiThumb["width"] - emojiHeight = emojiThumb["height"] - text = "\"#{emojiAlt}\"" + if run["emoji"]? + if run["emoji"]["isCustomEmoji"]?.try &.as_bool + if emojiImage = run.dig?("emoji", "image") + emojiAlt = emojiImage.dig?("accessibility", "accessibilityData", "label").try &.as_s || text + emojiThumb = emojiImage["thumbnails"][0] + text = "\"#{emojiAlt}\"" + else + # Hide deleted channel emoji + text = "" + end + end end text