diff options
| author | ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> | 2023-02-16 14:12:56 -0500 |
|---|---|---|
| committer | ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> | 2023-02-16 14:12:56 -0500 |
| commit | 76ad4e802603f82fe45d522a9c268e972d428a75 (patch) | |
| tree | e1ebbf92e0d7754185fbb5bf5bf7155628341487 /src | |
| parent | d03a62641f20a8dfd15fc9fe50373a5e75ee3d6e (diff) | |
| download | invidious-76ad4e802603f82fe45d522a9c268e972d428a75.tar.gz invidious-76ad4e802603f82fe45d522a9c268e972d428a75.tar.bz2 invidious-76ad4e802603f82fe45d522a9c268e972d428a75.zip | |
show member icon, hide deleted emojis, fix non-custom emojis
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/comments.cr | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 5749248e..f1942ceb 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 += " <i class=\"icon ion ion-md-checkmark-circle\"></i>" elsif child["verified"]?.try &.as_bool author_name += " <i class=\"icon ion ion-md-checkmark\"></i>" end + if child["isMember"]?.try &.as_bool + member_icon = "<img + alt=\"\" + src=\"/ggpht#{URI.parse(child["memberIconUrl"].as_s).request_target}\" + width=\"16\" + height=\"16\" + title=\"#{translate(locale, "Member")}\" + />" + end html << <<-END_HTML <div class="pure-g" style="width:100%"> <div class="channel-profile pure-u-4-24 pure-u-md-2-24"> @@ -343,6 +353,7 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false) <b> <a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a> </b> + #{member_icon} <p style="white-space:pre-wrap">#{child["contentHtml"]}</p> END_HTML @@ -678,13 +689,17 @@ def content_to_comment_html(content, video_id : String? = "") text = "<b>#{text}</b>" if run["bold"]? text = "<s>#{text}</s>" if run["strikethrough"]? text = "<i>#{text}</i>" 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 = "<img alt=\"#{emojiAlt}\" src=\"#{emojiUrl}\" width=\"#{emojiWidth}\" height=\"#{emojiHeight}\" style=\"margin-right:2px;margin-left:2px;\" />" + 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 = "<img alt=\"#{emojiAlt}\" src=\"/ggpht#{URI.parse(emojiThumb["url"].as_s).request_target}\" title=\"#{emojiAlt}\" width=\"#{emojiThumb["width"]}\" height=\"#{emojiThumb["height"]}\" style=\"margin-right:2px;margin-left:2px;\"/>" + else + # Hide deleted channel emoji + text = "" + end + end end text |
