diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr
index 2da76134..72f6727d 100644
--- a/src/invidious/routes/api/v1/channels.cr
+++ b/src/invidious/routes/api/v1/channels.cr
@@ -440,7 +440,8 @@ module Invidious::Routes::API::V1::Channels
else
comments = YoutubeAPI.browse(continuation: continuation)
end
- return Comments.parse_youtube(id, comments, format, locale, thin_mode, is_post: true)
+
+ return Comments.parse_youtube(id, comments, format, locale, thin_mode, "post")
end
def self.channels(env)
diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr
index 952098e0..c43d6fb7 100644
--- a/src/invidious/routes/channels.cr
+++ b/src/invidious/routes/channels.cr
@@ -268,7 +268,8 @@ 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, is_post: true))["contentHtml"]
+
+ comment_html = JSON.parse(Comments.parse_youtube(id, comments, "html", locale, thin_mode, "post"))["contentHtml"]
end
templated "post"
end
diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr
index aabe8dfc..c11b0108 100644
--- a/src/invidious/routes/watch.cr
+++ b/src/invidious/routes/watch.cr
@@ -332,4 +332,53 @@ module Invidious::Routes::Watch
return error_template(400, "Invalid label or itag")
end
end
+
+ # used for fetching replies/ fetching more comments when js is disabled.
+ def self.comments(env)
+ locale = env.get("preferences").as(Preferences).locale
+ region = env.params.query["region"]?
+
+ id = env.params.query["id"]
+ continuation = env.params.query["continuation"]?
+
+ source = env.params.query["source"]? || "youtube"
+
+ thin_mode = env.params.query["thin_mode"]? == "true"
+ comment_type = env.params.query["type"]? || "video"
+
+ parent_comment = nil
+ if comment_type == "community"
+ # community posts
+ comment_html = JSON.parse(fetch_channel_community(id, continuation, locale, "html", thin_mode))["contentHtml"]
+ elsif comment_type == "post"
+ # replies to a community post
+ ucid = env.params.query["ucid"]?
+ if ucid.nil?
+ response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
+ return error_json(400, "Invalid post ID") if response["error"]?
+ ucid = response.dig("endpoint", "browseEndpoint", "browseId").as_s
+ else
+ ucid = ucid.to_s
+ end
+ case continuation
+ when nil, ""
+ comments = Comments.fetch_community_post_comments(ucid, id)
+ else
+ comments = YoutubeAPI.browse(continuation: continuation)
+ end
+ comment_html = JSON.parse(Comments.parse_youtube(id, comments, "html", locale, thin_mode, "post"))["contentHtml"]
+ else
+ # video comments
+ if source == "youtube"
+ comment_html = JSON.parse(Comments.fetch_youtube(id, continuation, "html", locale, thin_mode, region))["contentHtml"]
+ elsif source == "reddit"
+ comments, reddit_thread = Comments.fetch_reddit(id)
+ comment_html = Frontend::Comments.template_reddit(comments, locale)
+
+ comment_html = Comments.fill_links(comment_html, "https", "www.reddit.com")
+ comment_html = Comments.replace_links(comment_html)
+ end
+ end
+ templated "comments_no_js"
+ end
end
diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr
index ba05da19..f16d8a4c 100644
--- a/src/invidious/routing.cr
+++ b/src/invidious/routing.cr
@@ -170,6 +170,8 @@ module Invidious::Routing
get "/embed/", Routes::Embed, :redirect
get "/embed/:id", Routes::Embed, :show
+ # currently only for fetching continuations when js is disabled.
+ get "/comment_viewer", Routes::Watch, :comments
end
def register_yt_playlist_routes
diff --git a/src/invidious/views/comments_no_js.ecr b/src/invidious/views/comments_no_js.ecr
new file mode 100644
index 00000000..f9c25432
--- /dev/null
+++ b/src/invidious/views/comments_no_js.ecr
@@ -0,0 +1,9 @@
+<% content_for "header" do %>
+
Invidious
+
+<% end %>
+
+
+
\ No newline at end of file
diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr
index d2a305d3..d79580cd 100644
--- a/src/invidious/views/community.ecr
+++ b/src/invidious/views/community.ecr
@@ -13,6 +13,7 @@
<% content_for "header" do %>
<%= author %> - Invidious
+
<% end %>
<%= rendered "components/channel_info" %>
@@ -27,7 +28,7 @@
<% else %>
<% end %>
diff --git a/src/invidious/views/post.ecr b/src/invidious/views/post.ecr
index fb03a44c..d4133ffe 100644
--- a/src/invidious/views/post.ecr
+++ b/src/invidious/views/post.ecr
@@ -1,10 +1,11 @@
<% content_for "header" do %>
<% if nojs %>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 45c58a16..54922ffd 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -42,6 +42,7 @@ we're going to need to do it here in order to allow for translations.
content: "<%= translate(locale, "Show less") %>"
}
+
<% end %>