diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-06-21 21:53:28 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-06-21 21:53:28 -0500 |
| commit | ca79e81b39563b7fac0f8d8d895068999b89d245 (patch) | |
| tree | a7eb9f0849cd4fa81b79c6f04e6c12806b0c4444 | |
| parent | a9e86cecf5dcc7c5b685bc80045b85cf90bd922b (diff) | |
| download | invidious-ca79e81b39563b7fac0f8d8d895068999b89d245.tar.gz invidious-ca79e81b39563b7fac0f8d8d895068999b89d245.tar.bz2 invidious-ca79e81b39563b7fac0f8d8d895068999b89d245.zip | |
Fix simpleText in comments extractor
| -rw-r--r-- | src/invidious/comments.cr | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 51c092ac..7f593760 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -114,8 +114,10 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_m comments = JSON.build do |json| json.object do if body["header"]? - comment_count = body["header"]["commentsHeaderRenderer"]["countText"]["runs"][0]? - .try &.["text"].as_s.gsub(/\D/, "").to_i? || 0 + count_text = body["header"]["commentsHeaderRenderer"]["countText"] + comment_count = (count_text["simpleText"]? || count_text["runs"]?.try &.[0]?.try &.["text"]?) + .try &.as_s.gsub(/\D/, "").to_i? || 0 + json.field "commentCount", comment_count end @@ -192,7 +194,8 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_m end if node_replies && !response["commentRepliesContinuation"]? - reply_count = node_replies["moreText"]["runs"][0]?.try &.["text"].as_s.gsub(/\D/, "").to_i? || 1 + reply_count = (node_replies["moreText"]["simpleText"]? || node_replies["moreText"]["runs"]?.try &.[0]?.try &.["text"]?) + .try &.as_s.gsub(/\D/, "").to_i? || 1 continuation = node_replies["continuations"]?.try &.as_a[0]["nextContinuationData"]["continuation"].as_s continuation ||= "" |
