From 55118a676883e6e5ce551ec6c22074893f38b8bc Mon Sep 17 00:00:00 2001 From: Agustin Ferrari Date: Wed, 30 Jan 2019 09:28:28 -0300 Subject: [PATCH 1/4] Change color to the links and add a couple of improvements in the comments --- assets/css/lighttheme.css | 2 +- src/invidious/comments.cr | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/css/lighttheme.css b/assets/css/lighttheme.css index 34bb9fc1..919d73f3 100644 --- a/assets/css/lighttheme.css +++ b/assets/css/lighttheme.css @@ -4,6 +4,6 @@ a:active { } a { - color: #303030; + color: #0093ff; text-decoration: none; } diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 87065b5f..3b9dd8eb 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -329,7 +329,9 @@ def template_youtube_comments(comments, locale) #{child["author"]}

#{child["contentHtml"]}

- #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64)))} + #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64)))} + | + [YT] | #{number_with_separator(child["likeCount"])}

From e9ea365f2f029f09fea9420d6820d19b67c179cc Mon Sep 17 00:00:00 2001 From: Agustin Ferrari Date: Thu, 31 Jan 2019 08:21:26 -0300 Subject: [PATCH 2/4] Add additional parameters in the API comments, highlight the user name in the uploader comments and I finished permalink of the comments. --- assets/css/default.css | 7 +++++++ src/invidious/comments.cr | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/assets/css/default.css b/assets/css/default.css index 244a5edd..e449df22 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -1,3 +1,10 @@ +.channel-owner { + background-color: #008BEC; + color: beige; + border-radius: 9px; + padding: 1px 6px; +} + .h-box { padding-left: 1em; padding-right: 1em; diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 3b9dd8eb..34113c97 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -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 json.field "commentCount", comment_count end + + json.field "videoId", id json.field "comments" 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 "likeCount", node_comment["likeCount"] 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"]? reply_count = node_replies["moreText"]["simpleText"].as_s.delete("View all reply replies,") @@ -326,12 +338,12 @@ def template_youtube_comments(comments, locale)

- #{child["author"]} + #{child["author"]}

#{child["contentHtml"]}

#{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64)))} | - [YT] + [YT] | #{number_with_separator(child["likeCount"])}

From b0ba670c919e4d1f4613ebc8973a8a1065dc4292 Mon Sep 17 00:00:00 2001 From: Agustin Ferrari Date: Fri, 1 Feb 2019 09:09:10 -0300 Subject: [PATCH 3/4] 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 --- assets/css/default.css | 33 +++++++++++++++++++++++++++++++++ locales/en-US.json | 6 +++++- src/invidious/comments.cr | 34 +++++++++++++++++++++++++++++----- 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/assets/css/default.css b/assets/css/default.css index e449df22..0f7e9eee 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -5,6 +5,39 @@ padding: 1px 6px; } +.creator-heart-container { + display: inline-block; + padding: 0px 7px 6px 0px; + margin: 0px -7px -4px 0px; +} + +.creator-heart { + position: relative; + width: 16px; + height: 16px; + border: 2px none; +} + +.creator-heart-background-hearted { + width: 16px; + height: 16px; + padding: 0px; + position: relative; +} + +.creator-heart-small-hearted { + position: absolute; + right: -7px; + bottom: -4px; +} + +.creator-heart-small-container { + position: relative; + width: 13px; + height: 13px; + color: rgb(255, 0, 0); +} + .h-box { padding-left: 1em; padding-right: 1em; diff --git a/locales/en-US.json b/locales/en-US.json index ccc01458..20fc019e 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -270,5 +270,9 @@ "News": "News", "Movies": "Movies", "Download": "Download", - "Download as: ": "Download as: " + "Download as: ": "Download as: ", + "%A %B %-d, %Y": "%A %B %-d, %Y", + "(edited)": "(edited)", + "Youtube permalink of the comment": "Youtube permalink of the comment", + "`x` marked it with a ❤": "`x` marked it with a ❤" } 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) #{child["author"]}

#{child["contentHtml"]}

- #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64)))} + #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64)))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""} | [YT] | #{number_with_separator(child["likeCount"])} + END_HTML + + if child["creatorHeart"]? + html += <<-END_HTML + +
+ +
+
🖤
+
+
+
+ END_HTML + end + + html += <<-END_HTML

#{replies_html}
From ceaddbc8211b727c07bc47aa77a9cac431702fbc Mon Sep 17 00:00:00 2001 From: Agustin Ferrari Date: Sat, 2 Feb 2019 20:13:40 -0300 Subject: [PATCH 4/4] Minor fixes in CSS colors --- assets/css/default.css | 4 ++-- assets/css/lighttheme.css | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/css/default.css b/assets/css/default.css index 0f7e9eee..800d529a 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -1,6 +1,6 @@ .channel-owner { background-color: #008BEC; - color: beige; + color: #fff; border-radius: 9px; padding: 1px 6px; } @@ -63,7 +63,7 @@ div { } button.pure-button-primary, -a.pure-button-primary { +a.pure-button-primary, .channel-owner:hover { background-color: #a0a0a0; color: rgba(35, 35, 35, 1); } diff --git a/assets/css/lighttheme.css b/assets/css/lighttheme.css index 919d73f3..1ecd2bd0 100644 --- a/assets/css/lighttheme.css +++ b/assets/css/lighttheme.css @@ -4,6 +4,6 @@ a:active { } a { - color: #0093ff; + color: #61809b; text-decoration: none; }