Fix YT link for post comments

pull/4176/head
ChunkyProgrammer 2023-10-16 12:46:23 -04:00
rodzic d290629e74
commit 01f5f2e9c5
5 zmienionych plików z 16 dodań i 9 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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
</div>
</div>
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
<a href="https://www.youtube.com/channel/#{comments["authorId"]}/community?lb=#{id}&lc=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|
END_HTML
elsif comments["videoId"]?
html << <<-END_HTML
<a href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|

Wyświetl plik

@ -394,8 +394,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)

Wyświetl plik

@ -231,8 +231,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

Wyświetl plik

@ -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"