diff --git a/src/invidious/data_structs/youtube/renderers/community_post.cr b/src/invidious/data_structs/youtube/renderers/community_post.cr index 954632c0..84fc0ee3 100644 --- a/src/invidious/data_structs/youtube/renderers/community_post.cr +++ b/src/invidious/data_structs/youtube/renderers/community_post.cr @@ -38,6 +38,7 @@ module YouTubeStructs property content_html : String property attachment : AttachmentType property likes : Int32 + property comments : Int32 property published : Time def to_json(locale, json : JSON::Builder) @@ -52,6 +53,7 @@ module YouTubeStructs json.field "contents", html_to_content(self.content_html) json.field "attachment", self.attachment.to_json json.field "likes", self.likes + json.field "comments", self.comments json.field "published", self.published.to_unix end end diff --git a/src/invidious/helpers/extractors.cr b/src/invidious/helpers/extractors.cr index b2aff56a..654e0952 100644 --- a/src/invidious/helpers/extractors.cr +++ b/src/invidious/helpers/extractors.cr @@ -358,21 +358,27 @@ private module Parsers end end - likes = short_text_to_number(item_contents["voteCount"]["simpleText"].as_s.split(" ")[0]) # Youtube doesn't provide dislikes... - published = item_contents["publishedTimeText"]?.try &.["simpleText"]?.try { |t| decode_date(t.as_s) } || Time.local + # YouTube doesn't provide dislikes. + likes = short_text_to_number(item_contents["voteCount"]["simpleText"].as_s.split(" ")[0]) - YouTubeStructs::CommunityPost.new({ - author: author_name, - author_id: author_id, - author_thumbnail: author_thumbnail, - post_id: post_id, - content_html: contents, - attachment: attachment, - likes: likes, - published: published, + comments = item_contents.dig?("actionButtons", "commentActionButtonsRenderer", + "replyButton", "buttonRenderer", "text", "simpleText").try { |t| short_text_to_number(t.as_s) } || 0 + + published = item_contents["publishedTimeText"]?.try &.["simpleText"]?.try { |t| decode_date(t.as_s) } || Time.local + + YouTubeStructs::CommunityPost.new({ + author: author_name, + author_id: author_id, + author_thumbnail: author_thumbnail, + post_id: post_id, + content_html: contents, + attachment: attachment, + likes: likes, + comments: comments, + published: published, }) end - end +end end # The following are the extractors for extracting an array of items from diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index 71c5d2e2..23042d56 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -74,24 +74,30 @@ -

><%= thread.author %>

<%= thread.content_html -%>

<% # Handles attachments: %> <% attachment = thread.attachment %> - <% if attachment.is_a? YouTubeStructs::VideoRenderer %> -
- -
- <% elsif attachment.is_a? YouTubeStructs::PlaylistRenderer %> - <% elsif attachment.is_a? YouTubeStructs::CommunityPoll %> - <% elsif attachment.nil? %> - <% else %> - - <% end %> - -

<%= thread.likes %>

+
+ <% if attachment.is_a? YouTubeStructs::VideoRenderer %> +
+ +
+ <% elsif attachment.is_a? YouTubeStructs::PlaylistRenderer %> + <% elsif attachment.is_a? YouTubeStructs::CommunityPoll %> + <% elsif attachment.nil? %> + <% else %> + + <% end %> +
+
+
+ +
<%- end%>