This commit is contained in:
syeopite 2021-08-14 18:42:13 -07:00
parent 2a32f84332
commit 38110801a7
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82

View file

@ -358,28 +358,28 @@ private module Parsers
end
end
# YouTube doesn't provide dislikes.
likes = short_text_to_number(item_contents["voteCount"]["simpleText"].as_s.split(" ")[0])
# YouTube doesn't provide dislikes.
likes = short_text_to_number(item_contents["voteCount"]["simpleText"].as_s.split(" ")[0])
comments = item_contents.dig?("actionButtons", "commentActionButtonsRenderer",
"replyButton", "buttonRenderer", "text", "simpleText").try { |t| short_text_to_number(t.as_s) } || 0
comments = item_contents.dig?("actionButtons", "commentActionButtonsRenderer",
"replyButton", "buttonRenderer", "text", "simpleText").try { |t| short_text_to_number(t.as_s) } || 0
published = item_contents["publishedTimeText"]["runs"][0]["text"].try { |t| decode_date(t.as_s.rstrip(" (edited)")) } || Time.local
published = item_contents["publishedTimeText"]["runs"][0]["text"].try { |t| decode_date(t.as_s.rstrip(" (edited)")) } || Time.local
YouTubeStructs::CommunityPost.new({
author: author_name,
author_id: author_id,
author_thumbnail: author_thumbnail,
post_id: post_id,
content_html: contents,
attachment: attachment,
likes: likes,
comments: comments,
published: published,
})
YouTubeStructs::CommunityPost.new({
author: author_name,
author_id: author_id,
author_thumbnail: author_thumbnail,
post_id: post_id,
content_html: contents,
attachment: attachment,
likes: likes,
comments: comments,
published: published,
})
end
end
end
end
# The following are the extractors for extracting an array of items from
# the internal Youtube API's JSON response. The result is then packaged into