mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Fix simpleText in comments extractor
This commit is contained in:
parent
a9e86cecf5
commit
ca79e81b39
1 changed files with 6 additions and 3 deletions
|
@ -114,8 +114,10 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_m
|
||||||
comments = JSON.build do |json|
|
comments = JSON.build do |json|
|
||||||
json.object do
|
json.object do
|
||||||
if body["header"]?
|
if body["header"]?
|
||||||
comment_count = body["header"]["commentsHeaderRenderer"]["countText"]["runs"][0]?
|
count_text = body["header"]["commentsHeaderRenderer"]["countText"]
|
||||||
.try &.["text"].as_s.gsub(/\D/, "").to_i? || 0
|
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
|
json.field "commentCount", comment_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -192,7 +194,8 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_m
|
||||||
end
|
end
|
||||||
|
|
||||||
if node_replies && !response["commentRepliesContinuation"]?
|
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 = node_replies["continuations"]?.try &.as_a[0]["nextContinuationData"]["continuation"].as_s
|
||||||
continuation ||= ""
|
continuation ||= ""
|
||||||
|
|
Loading…
Reference in a new issue