Add additional parameters in the API comments, highlight the user name in the uploader comments and I finished permalink of the comments.

This commit is contained in:
Agustin Ferrari 2019-01-31 08:21:26 -03:00
parent 55118a6768
commit e9ea365f2f
2 changed files with 21 additions and 2 deletions

View File

@ -1,3 +1,10 @@
.channel-owner {
background-color: #008BEC;
color: beige;
border-radius: 9px;
padding: 1px 6px;
}
.h-box { .h-box {
padding-left: 1em; padding-left: 1em;
padding-right: 1em; padding-right: 1em;

View File

@ -158,6 +158,8 @@ def fetch_youtube_comments(id, continuation, proxies, format, locale)
comment_count = body["header"]["commentsHeaderRenderer"]["countText"]["simpleText"].as_s.delete("Comments,").to_i comment_count = body["header"]["commentsHeaderRenderer"]["countText"]["simpleText"].as_s.delete("Comments,").to_i
json.field "commentCount", comment_count json.field "commentCount", comment_count
end end
json.field "videoId", id
json.field "comments" do json.field "comments" do
json.array do json.array do
@ -217,6 +219,16 @@ def fetch_youtube_comments(id, continuation, proxies, format, locale)
json.field "publishedText", translate(locale, "`x` ago", recode_date(published)) json.field "publishedText", translate(locale, "`x` ago", recode_date(published))
json.field "likeCount", node_comment["likeCount"] json.field "likeCount", node_comment["likeCount"]
json.field "commentId", node_comment["commentId"] json.field "commentId", node_comment["commentId"]
json.field "authorIsChannelOwner", node_comment["authorIsChannelOwner"]
if node_comment["creatorHeart"]?
json.field "creatorHeart" do
json.object do
json.field "creatorThumbnail", node_comment["creatorHeart"]["creatorHeartRenderer"]["creatorThumbnail"]["thumbnails"][2]
json.field "creatorName", node_comment["creatorHeart"]["creatorHeartRenderer"]["creatorThumbnail"]["accessibility"]["accessibilityData"]["label"]
end
end
end
if node_replies && !response["commentRepliesContinuation"]? if node_replies && !response["commentRepliesContinuation"]?
reply_count = node_replies["moreText"]["simpleText"].as_s.delete("View all reply replies,") reply_count = node_replies["moreText"]["simpleText"].as_s.delete("View all reply replies,")
@ -326,12 +338,12 @@ def template_youtube_comments(comments, locale)
<div class="pure-u-20-24 pure-u-md-22-24"> <div class="pure-u-20-24 pure-u-md-22-24">
<p> <p>
<b> <b>
<a href="#{child["authorUrl"]}">#{child["author"]}</a> <a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{child["author"]}</a>
</b> </b>
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p> <p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
<span title="#{Time.unix(child["published"].as_i64).to_s(translate(locale,"%A %B %-d, %Y"))}">#{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64)))}</span> <span title="#{Time.unix(child["published"].as_i64).to_s(translate(locale,"%A %B %-d, %Y"))}">#{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64)))}</span>
| |
<a href="https://www.youtube.com/watch?v=%s&lc=#{child["commentId"]}" title="#{translate(locale, "Youtube permalink of the comment")}">[YT]</a> <a href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{translate(locale, "Youtube permalink of the comment")}">[YT]</a>
| |
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])} <i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
</p> </p>