mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-23 05:33:07 +05:30
Fix YT link for post comments
This commit is contained in:
parent
71da6c2fec
commit
0c414adbeb
@ -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
|
||||
|
@ -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 rel="noreferrer noopener" href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|
||||
|
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user