diff options
| author | Agustin Ferrari <agustinferrari@gmx.com> | 2019-02-01 09:09:10 -0300 |
|---|---|---|
| committer | Agustin Ferrari <agustinferrari@gmx.com> | 2019-02-01 09:09:10 -0300 |
| commit | b0ba670c919e4d1f4613ebc8973a8a1065dc4292 (patch) | |
| tree | 3e44ed6c873221cd8997e9b4a084908d1abd7ebf /src | |
| parent | e9ea365f2f029f09fea9420d6820d19b67c179cc (diff) | |
| download | invidious-b0ba670c919e4d1f4613ebc8973a8a1065dc4292.tar.gz invidious-b0ba670c919e4d1f4613ebc8973a8a1065dc4292.tar.bz2 invidious-b0ba670c919e4d1f4613ebc8973a8a1065dc4292.zip | |
Comments now show if they were edited and if they received a heart from the uploader (plus additional classes in default.css). The isEdited attribute was also added in the comments API and new strings in en-US.json
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/comments.cr | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 34113c97..e6d74d1d 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -211,7 +211,14 @@ def fetch_youtube_comments(id, continuation, proxies, format, locale) json.field "authorUrl", "" end - published = decode_date(node_comment["publishedTimeText"]["runs"][0]["text"].as_s.rchop(" (edited)")) + published_text = node_comment["publishedTimeText"]["runs"][0]["text"].as_s + published = decode_date(published_text.rchop(" (edited)")) + + if published_text.includes?(" (edited)") + json.field "isEdited", true + else + json.field "isEdited", false + end json.field "content", content json.field "contentHtml", content_html @@ -221,11 +228,12 @@ def fetch_youtube_comments(id, continuation, proxies, format, locale) json.field "commentId", node_comment["commentId"] json.field "authorIsChannelOwner", node_comment["authorIsChannelOwner"] - if node_comment["creatorHeart"]? + if node_comment["actionButtons"]["commentActionButtonsRenderer"]["creatorHeart"]? + hearth_data = node_comment["actionButtons"]["commentActionButtonsRenderer"]["creatorHeart"]["creatorHeartRenderer"]["creatorThumbnail"] 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"] + json.field "creatorThumbnail", hearth_data["thumbnails"][-1]["url"] + json.field "creatorName", hearth_data["accessibility"]["accessibilityData"]["label"] end end end @@ -341,11 +349,27 @@ def template_youtube_comments(comments, locale) <a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{child["author"]}</a> </b> <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)))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""}</span> | <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"])} + END_HTML + + if child["creatorHeart"]? + html += <<-END_HTML + <span class="creator-heart-container" title="#{translate(locale, "`x` marked it with a ❤", child["creatorHeart"]["creatorName"].as_s)}"> + <div class="creator-heart"> + <img class="creator-heart-background-hearted" src="#{child["creatorHeart"]["creatorThumbnail"]}"></img> + <div class="creator-heart-small-hearted"> + <div class="creator-heart-small-container">🖤</div> + </div> + </div> + </span> + END_HTML + end + + html += <<-END_HTML </p> #{replies_html} </div> |
