diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-08-07 08:30:37 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-08-07 08:30:37 -0500 |
| commit | 1da69d095c15223b28cacbdae4b8ea2819fb96e7 (patch) | |
| tree | 5708c43a4f0236479b4499d0e237f8dfeccab0b1 | |
| parent | 4b962dddd30fac0b4a5b058b5d18c014239a224d (diff) | |
| download | invidious-1da69d095c15223b28cacbdae4b8ea2819fb96e7.tar.gz invidious-1da69d095c15223b28cacbdae4b8ea2819fb96e7.tar.bz2 invidious-1da69d095c15223b28cacbdae4b8ea2819fb96e7.zip | |
Allow comment author info to be blank
| -rw-r--r-- | src/invidious.cr | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 9ad2e9b2..986a0ab3 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1770,7 +1770,10 @@ get "/api/v1/comments/:id" do |env| content_text ||= node_comment["contentText"]["runs"].as_a.map { |comment| comment["text"] } .join("").rchop('\ufeff') - json.field "author", node_comment["authorText"]["simpleText"] + author = node_comment["authorText"]?.try &.["simpleText"] + author ||= "" + + json.field "author", author json.field "authorThumbnails" do json.array do node_comment["authorThumbnail"]["thumbnails"].as_a.each do |thumbnail| @@ -1782,8 +1785,15 @@ get "/api/v1/comments/:id" do |env| end end end - json.field "authorId", node_comment["authorEndpoint"]["browseEndpoint"]["browseId"] - json.field "authorUrl", node_comment["authorEndpoint"]["browseEndpoint"]["canonicalBaseUrl"] + + if node_comment["authorEndpoint"]? + json.field "authorId", node_comment["authorEndpoint"]["browseEndpoint"]["browseId"] + json.field "authorUrl", node_comment["authorEndpoint"]["browseEndpoint"]["canonicalBaseUrl"] + else + json.field "authorId", "" + json.field "authorUrl", "" + end + json.field "content", content_text json.field "published", node_comment["publishedTimeText"]["runs"][0]["text"] json.field "likeCount", node_comment["likeCount"] |
