summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2020-02-01 12:14:37 -0500
committerOmar Roth <omarroth@protonmail.com>2020-02-01 12:14:37 -0500
commit9841f74adc94a4845aea6aace8d2408c3255dfa7 (patch)
treebe2be6a393e9bad8c2106bc53a5fa94ae5ecb687
parentb56e493d92157dcddbc65b2eaa3d93bb758e8544 (diff)
downloadinvidious-9841f74adc94a4845aea6aace8d2408c3255dfa7.tar.gz
invidious-9841f74adc94a4845aea6aace8d2408c3255dfa7.tar.bz2
invidious-9841f74adc94a4845aea6aace8d2408c3255dfa7.zip
Add handling for comments with no content
-rw-r--r--src/invidious/channels.cr8
-rw-r--r--src/invidious/comments.cr4
2 files changed, 5 insertions, 7 deletions
diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr
index 7cd1bef1..cddeed39 100644
--- a/src/invidious/channels.cr
+++ b/src/invidious/channels.cr
@@ -628,15 +628,13 @@ def fetch_channel_community(ucid, continuation, locale, config, kemal_config, fo
post = post["backstagePostThreadRenderer"]?.try &.["post"]["backstagePostRenderer"]? ||
post["commentThreadRenderer"]?.try &.["comment"]["commentRenderer"]?
- if !post
- next
- end
+ next if !post
if !post["contentText"]?
content_html = ""
else
- content_html = post["contentText"]["simpleText"]?.try &.as_s.rchop('\ufeff').try { |block| HTML.escape(block) }.to_s ||
- content_to_comment_html(post["contentText"]["runs"].as_a).try &.to_s || ""
+ content_html = post["contentText"]["simpleText"]?.try &.as_s.rchop('\ufeff').try { |b| HTML.escape(b) }.to_s ||
+ post["contentText"]["runs"]?.try &.as_a.try { |r| content_to_comment_html(r).try &.to_s } || ""
end
author = post["authorText"]?.try &.["simpleText"]? || ""
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 1d32d1f4..9e4d3866 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -150,8 +150,8 @@ def fetch_youtube_comments(id, db, cursor, format, locale, thin_mode, region, so
node_comment = node["commentRenderer"]
end
- content_html = node_comment["contentText"]["simpleText"]?.try &.as_s.rchop('\ufeff').try { |block| HTML.escape(block) }.to_s ||
- content_to_comment_html(node_comment["contentText"]["runs"].as_a).try &.to_s || ""
+ content_html = node_comment["contentText"]["simpleText"]?.try &.as_s.rchop('\ufeff').try { |b| HTML.escape(b) }.to_s ||
+ node_comment["contentText"]["runs"]?.try &.as_a.try { |r| content_to_comment_html(r).try &.to_s } || ""
author = node_comment["authorText"]?.try &.["simpleText"]? || ""
json.field "author", author