show member icon, hide deleted emojis, fix non-custom emojis
This commit is contained in:
parent
d03a62641f
commit
76ad4e8026
|
@ -405,6 +405,7 @@
|
||||||
"YouTube comment permalink": "YouTube comment permalink",
|
"YouTube comment permalink": "YouTube comment permalink",
|
||||||
"permalink": "permalink",
|
"permalink": "permalink",
|
||||||
"`x` marked it with a ❤": "`x` marked it with a ❤",
|
"`x` marked it with a ❤": "`x` marked it with a ❤",
|
||||||
|
"Member": "Member",
|
||||||
"Audio mode": "Audio mode",
|
"Audio mode": "Audio mode",
|
||||||
"Video mode": "Video mode",
|
"Video mode": "Video mode",
|
||||||
"Playlists": "Playlists",
|
"Playlists": "Playlists",
|
||||||
|
|
|
@ -328,11 +328,21 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false)
|
||||||
end
|
end
|
||||||
|
|
||||||
author_name = HTML.escape(child["author"].as_s)
|
author_name = HTML.escape(child["author"].as_s)
|
||||||
|
member_icon = ""
|
||||||
if child["verified"]?.try &.as_bool && child["authorIsChannelOwner"]?.try &.as_bool
|
if child["verified"]?.try &.as_bool && child["authorIsChannelOwner"]?.try &.as_bool
|
||||||
author_name += " <i class=\"icon ion ion-md-checkmark-circle\"></i>"
|
author_name += " <i class=\"icon ion ion-md-checkmark-circle\"></i>"
|
||||||
elsif child["verified"]?.try &.as_bool
|
elsif child["verified"]?.try &.as_bool
|
||||||
author_name += " <i class=\"icon ion ion-md-checkmark\"></i>"
|
author_name += " <i class=\"icon ion ion-md-checkmark\"></i>"
|
||||||
end
|
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
|
html << <<-END_HTML
|
||||||
<div class="pure-g" style="width:100%">
|
<div class="pure-g" style="width:100%">
|
||||||
<div class="channel-profile pure-u-4-24 pure-u-md-2-24">
|
<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>
|
<b>
|
||||||
<a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a>
|
<a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a>
|
||||||
</b>
|
</b>
|
||||||
|
#{member_icon}
|
||||||
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
|
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
|
||||||
END_HTML
|
END_HTML
|
||||||
|
|
||||||
|
@ -678,13 +689,17 @@ def content_to_comment_html(content, video_id : String? = "")
|
||||||
text = "<b>#{text}</b>" if run["bold"]?
|
text = "<b>#{text}</b>" if run["bold"]?
|
||||||
text = "<s>#{text}</s>" if run["strikethrough"]?
|
text = "<s>#{text}</s>" if run["strikethrough"]?
|
||||||
text = "<i>#{text}</i>" if run["italics"]?
|
text = "<i>#{text}</i>" if run["italics"]?
|
||||||
if emojiImage = run.dig?("emoji", "image")
|
if run["emoji"]?
|
||||||
emojiAlt = emojiImage.dig?("accessibility", "accessibilityData", "label").try &.as_s || text
|
if run["emoji"]["isCustomEmoji"]?.try &.as_bool
|
||||||
emojiThumb = emojiImage["thumbnails"][0]
|
if emojiImage = run.dig?("emoji", "image")
|
||||||
emojiUrl = "/ggpht#{URI.parse(emojiThumb["url"].as_s).request_target}"
|
emojiAlt = emojiImage.dig?("accessibility", "accessibilityData", "label").try &.as_s || text
|
||||||
emojiWidth = emojiThumb["width"]
|
emojiThumb = emojiImage["thumbnails"][0]
|
||||||
emojiHeight = emojiThumb["height"]
|
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;\"/>"
|
||||||
text = "<img alt=\"#{emojiAlt}\" src=\"#{emojiUrl}\" width=\"#{emojiWidth}\" height=\"#{emojiHeight}\" style=\"margin-right:2px;margin-left:2px;\" />"
|
else
|
||||||
|
# Hide deleted channel emoji
|
||||||
|
text = ""
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
text
|
text
|
||||||
|
|
Loading…
Reference in New Issue