diff --git a/src/invidious/comments/youtube.cr b/src/invidious/comments/youtube.cr index ec5adf65..857c0027 100644 --- a/src/invidious/comments/youtube.cr +++ b/src/invidious/comments/youtube.cr @@ -57,7 +57,7 @@ module Invidious::Comments return initial_data end - def parse_youtube(id, response, format, locale, thin_mode, type="video", sort_by = "top") + def parse_youtube(id, response, format, locale, thin_mode, sort_by = "top", type = "video", ucid = nil) contents = nil if on_response_received_endpoints = response["onResponseReceivedEndpoints"]? @@ -115,6 +115,10 @@ module Invidious::Comments json.field "commentCount", comment_count end + if !ucid.nil? + json.field "authorId", ucid + end + if type == "post" json.field "postId", id else diff --git a/src/invidious/frontend/comments_youtube.cr b/src/invidious/frontend/comments_youtube.cr index fb9b3223..08def85c 100644 --- a/src/invidious/frontend/comments_youtube.cr +++ b/src/invidious/frontend/comments_youtube.cr @@ -1,7 +1,7 @@ module Invidious::Frontend::Comments extend self - def template_youtube(comments, locale, thin_mode, id, type="video", is_replies = false) + def template_youtube(comments, locale, thin_mode, id, type = "video", is_replies = false) String.build do |html| root = comments["comments"].as_a root.each do |child| @@ -27,7 +27,7 @@ module Invidious::Frontend::Comments END_HTML - elsif comments["authorId"]? && !comments["singlePost"]? + elsif comments["authorId"]? && !comments["singlePost"]? && type != "post" # for posts we should display a link to the post replies_count_text = translate_count(locale, "comments_view_x_replies", @@ -151,7 +151,12 @@ module Invidious::Frontend::Comments | END_HTML - if comments["videoId"]? + if type == "post" && !comments["singlePost"]? + html << <<-END_HTML + [YT] + | + END_HTML + elsif comments["videoId"]? html << <<-END_HTML [YT] | diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr index 47837085..60b389d6 100644 --- a/src/invidious/routes/api/v1/channels.cr +++ b/src/invidious/routes/api/v1/channels.cr @@ -441,8 +441,7 @@ module Invidious::Routes::API::V1::Channels else comments = YoutubeAPI.browse(continuation: continuation) end - - return Comments.parse_youtube(id, comments, format, locale, thin_mode, "post") + return Comments.parse_youtube(id, comments, format, locale, thin_mode, type: "post", ucid: ucid) end def self.channels(env) diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 41fbd2d7..f3e4abd6 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -270,8 +270,7 @@ module Invidious::Routes::Channels if nojs comments = Comments.fetch_community_post_comments(ucid, id) - - comment_html = JSON.parse(Comments.parse_youtube(id, comments, "html", locale, thin_mode, "post"))["contentHtml"] + comment_html = JSON.parse(Comments.parse_youtube(id, comments, "html", locale, thin_mode, type: "post", ucid: ucid))["contentHtml"] end templated "post" end diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index c11b0108..ad64f53f 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -366,7 +366,7 @@ module Invidious::Routes::Watch else comments = YoutubeAPI.browse(continuation: continuation) end - comment_html = JSON.parse(Comments.parse_youtube(id, comments, "html", locale, thin_mode, "post"))["contentHtml"] + comment_html = JSON.parse(Comments.parse_youtube(id, comments, "html", locale, thin_mode, type: "post", ucid: ucid))["contentHtml"] else # video comments if source == "youtube"