diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-11-10 09:05:26 -0600 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-11-10 09:05:44 -0600 |
| commit | b9e2fee2c9afe816fc1cc20f73d444f1a258b3ef (patch) | |
| tree | 16ac4c5ae2fe5d2b952c5ceab7a7fcf8415b05fa | |
| parent | 0c8a1d46bdd7d4c171c0591c96c0d725d45fb5ea (diff) | |
| download | invidious-b9e2fee2c9afe816fc1cc20f73d444f1a258b3ef.tar.gz invidious-b9e2fee2c9afe816fc1cc20f73d444f1a258b3ef.tar.bz2 invidious-b9e2fee2c9afe816fc1cc20f73d444f1a258b3ef.zip | |
Fix templating for videos with 0 comments
| -rw-r--r-- | src/invidious.cr | 21 | ||||
| -rw-r--r-- | src/invidious/comments.cr | 17 |
2 files changed, 18 insertions, 20 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index c7de22fb..f267d7c1 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2041,26 +2041,7 @@ get "/api/v1/comments/:id" do |env| halt env, status_code: 500, response: error_message end - if format == "json" - next comments - else - comments = JSON.parse(comments) - content_html = template_youtube_comments(comments) - - response = JSON.build do |json| - json.object do - json.field "contentHtml", content_html - - if comments["commentCount"]? - json.field "commentCount", comments["commentCount"] - else - json.field "commentCount", 0 - end - end - end - - next response - end + next comments elsif source == "reddit" begin comments, reddit_thread = fetch_reddit_comments(id) diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index a699aaac..ba5d6f08 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -264,6 +264,23 @@ def fetch_youtube_comments(id, continuation, proxies, format) end end + if format == "html" + comments = JSON.parse(comments) + content_html = template_youtube_comments(comments) + + comments = JSON.build do |json| + json.object do + json.field "contentHtml", content_html + + if comments["commentCount"]? + json.field "commentCount", comments["commentCount"] + else + json.field "commentCount", 0 + end + end + end + end + return comments end |
