summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-03-09 10:47:50 -0600
committerOmar Roth <omarroth@hotmail.com>2018-03-09 10:47:50 -0600
commitd9c89f7e3fef4e159dd5c9f17fc8f809d1ef7a15 (patch)
treed1994d8cf17b92af3c2a26b6a71d8e07eee72818
parentcaf82ccb8f12afa6ff7d664bbd023074e36fefaf (diff)
downloadinvidious-d9c89f7e3fef4e159dd5c9f17fc8f809d1ef7a15.tar.gz
invidious-d9c89f7e3fef4e159dd5c9f17fc8f809d1ef7a15.tar.bz2
invidious-d9c89f7e3fef4e159dd5c9f17fc8f809d1ef7a15.zip
Limit number of reddit comments
-rw-r--r--src/helpers.cr6
-rw-r--r--src/views/watch.ecr2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/helpers.cr b/src/helpers.cr
index 8127c4bc..a3e3ba5d 100644
--- a/src/helpers.cr
+++ b/src/helpers.cr
@@ -257,12 +257,12 @@ end
def get_reddit_comments(id, client, headers)
query = "(url:3D#{id}%20OR%20url:#{id})%20(site:youtube.com%20OR%20site:youtu.be)"
search_results = client.get("/search.json?q=#{query}", headers)
-
+
if search_results.status_code == 200
search_results = RedditSubmit.from_json(search_results.body)
-
+
thread = search_results.data.children.sort_by { |child| child.data.score }[-1]
- result = client.get("/r/#{thread.data.subreddit}/comments/#{thread.data.id}?sort=top&depth=3", headers).body
+ result = client.get("/r/#{thread.data.subreddit}/comments/#{thread.data.id}?limit=100&sort=top", headers).body
result = JSON.parse(result)
elsif search_results.status_code == 302
search_results = client.get(search_results.headers["Location"], headers).body
diff --git a/src/views/watch.ecr b/src/views/watch.ecr
index 44fc4257..a07dd2e5 100644
--- a/src/views/watch.ecr
+++ b/src/views/watch.ecr
@@ -109,7 +109,7 @@ function toggle(target) {
<div style="margin-right:1em; overflow-wrap:break-word; word-wrap:break-word;">
<h3><%= reddit_thread.data.title %></h3>
<b>
- <a target="_blank" href="https://reddit.com<%= reddit_thread.data.permalink %>">View comments on Reddit</a>
+ <a target="_blank" href="https://reddit.com<%= reddit_thread.data.permalink %>">View more comments on Reddit</a>
</b>
<%= reddit_html %>
</div>