|
|
@ -182,10 +182,10 @@ def fetch_youtube_comments(id, cursor, format, locale, thin_mode, region, sort_b
|
|
|
|
json.field "contentHtml", content_html
|
|
|
|
json.field "contentHtml", content_html
|
|
|
|
|
|
|
|
|
|
|
|
json.field "isPinned", (node_comment["pinnedCommentBadge"]? != nil)
|
|
|
|
json.field "isPinned", (node_comment["pinnedCommentBadge"]? != nil)
|
|
|
|
json.field "isMember", (node_comment["sponsorCommentBadge"]? != nil)
|
|
|
|
json.field "isSponsor", (node_comment["sponsorCommentBadge"]? != nil)
|
|
|
|
if node_comment["sponsorCommentBadge"]?
|
|
|
|
if node_comment["sponsorCommentBadge"]?
|
|
|
|
# Member icon thumbnails always have one object and there's only ever the url property in it
|
|
|
|
# Sponsor icon thumbnails always have one object and there's only ever the url property in it
|
|
|
|
json.field "memberIconUrl", node_comment["sponsorCommentBadge"]["sponsorCommentBadgeRenderer"]["customBadge"]["thumbnails"][0]["url"].to_s
|
|
|
|
json.field "sponsorIconUrl", node_comment.dig("sponsorCommentBadge", "sponsorCommentBadgeRenderer", "customBadge", "thumbnails", 0, "url").to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
json.field "published", published.to_unix
|
|
|
|
json.field "published", published.to_unix
|
|
|
|
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
|
|
|
|
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
|
|
|
@ -328,20 +328,19 @@ 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 = ""
|
|
|
|
sponsor_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
|
|
|
|
if child["isSponsor"].as_bool
|
|
|
|
member_icon = "<img
|
|
|
|
sponsor_icon = String.build do |str|
|
|
|
|
alt=\"\"
|
|
|
|
str << %(<img alt="")
|
|
|
|
src=\"/ggpht#{URI.parse(child["memberIconUrl"].as_s).request_target}\"
|
|
|
|
str << %(src="/ggpht) << URI.parse(child["sponsorIconUrl"].as_s).request_target << '"'
|
|
|
|
width=\"16\"
|
|
|
|
str << %(title=") << translate(locale, "Channel Sponsor") << '"'
|
|
|
|
height=\"16\"
|
|
|
|
str << %(width="16" height="16"/>)
|
|
|
|
title=\"#{translate(locale, "Member")}\"
|
|
|
|
end
|
|
|
|
/>"
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
html << <<-END_HTML
|
|
|
|
html << <<-END_HTML
|
|
|
|
<div class="pure-g" style="width:100%">
|
|
|
|
<div class="pure-g" style="width:100%">
|
|
|
@ -353,7 +352,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}
|
|
|
|
#{sponsor_icon}
|
|
|
|
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
|
|
|
|
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
|
|
|
|
END_HTML
|
|
|
|
END_HTML
|
|
|
|
|
|
|
|
|
|
|
@ -689,12 +688,21 @@ 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"]?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# check for custom emojis
|
|
|
|
if run["emoji"]?
|
|
|
|
if run["emoji"]?
|
|
|
|
if run["emoji"]["isCustomEmoji"]?.try &.as_bool
|
|
|
|
if run["emoji"]["isCustomEmoji"]?.try &.as_bool
|
|
|
|
if emojiImage = run.dig?("emoji", "image")
|
|
|
|
if emojiImage = run.dig?("emoji", "image")
|
|
|
|
emojiAlt = emojiImage.dig?("accessibility", "accessibilityData", "label").try &.as_s || text
|
|
|
|
emojiAlt = emojiImage.dig?("accessibility", "accessibilityData", "label").try &.as_s || text
|
|
|
|
emojiThumb = emojiImage["thumbnails"][0]
|
|
|
|
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;\"/>"
|
|
|
|
text = String.build do |str|
|
|
|
|
|
|
|
|
str << %(<img alt=") << emojiAlt << '"'
|
|
|
|
|
|
|
|
str << %(src="/ggpht) << URI.parse(emojiThumb["url"].as_s).request_target << '"'
|
|
|
|
|
|
|
|
str << %(title=") << emojiAlt << '"'
|
|
|
|
|
|
|
|
str << %(width=") << emojiThumb["width"] << '"'
|
|
|
|
|
|
|
|
str << %(height=") << emojiThumb["height"] << '"'
|
|
|
|
|
|
|
|
str << %( style="margin-right:2px;margin-left:2px;"/>)
|
|
|
|
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
# Hide deleted channel emoji
|
|
|
|
# Hide deleted channel emoji
|
|
|
|
text = ""
|
|
|
|
text = ""
|
|
|
|