|
|
@ -423,42 +423,41 @@ private module Parsers
|
|
|
|
"overlay", "reelPlayerOverlayRenderer"
|
|
|
|
"overlay", "reelPlayerOverlayRenderer"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Sometimes, the "reelPlayerOverlayRenderer" object is missing the
|
|
|
|
if video_details_container = reel_player_overlay.dig?(
|
|
|
|
# important part of the response. We use this exception to tell
|
|
|
|
"reelPlayerHeaderSupportedRenderers",
|
|
|
|
# the calling function to fetch the content again.
|
|
|
|
"reelPlayerHeaderRenderer"
|
|
|
|
if !reel_player_overlay.as_h.has_key?("reelPlayerHeaderSupportedRenderers")
|
|
|
|
)
|
|
|
|
raise RetryOnceException.new
|
|
|
|
# Author infos
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
video_details_container = reel_player_overlay.dig(
|
|
|
|
|
|
|
|
"reelPlayerHeaderSupportedRenderers",
|
|
|
|
|
|
|
|
"reelPlayerHeaderRenderer"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Author infos
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
author = video_details_container
|
|
|
|
author = video_details_container
|
|
|
|
.dig?("channelTitleText", "runs", 0, "text")
|
|
|
|
.dig?("channelTitleText", "runs", 0, "text")
|
|
|
|
.try &.as_s || author_fallback.name
|
|
|
|
.try &.as_s || author_fallback.name
|
|
|
|
|
|
|
|
|
|
|
|
ucid = video_details_container
|
|
|
|
ucid = video_details_container
|
|
|
|
.dig?("channelNavigationEndpoint", "browseEndpoint", "browseId")
|
|
|
|
.dig?("channelNavigationEndpoint", "browseEndpoint", "browseId")
|
|
|
|
.try &.as_s || author_fallback.id
|
|
|
|
.try &.as_s || author_fallback.id
|
|
|
|
|
|
|
|
|
|
|
|
# Title & publication date
|
|
|
|
# Title & publication date
|
|
|
|
|
|
|
|
|
|
|
|
title = video_details_container.dig?("reelTitleText")
|
|
|
|
title = video_details_container.dig?("reelTitleText")
|
|
|
|
.try { |t| extract_text(t) } || ""
|
|
|
|
.try { |t| extract_text(t) } || ""
|
|
|
|
|
|
|
|
|
|
|
|
published = video_details_container
|
|
|
|
published = video_details_container
|
|
|
|
.dig?("timestampText", "simpleText")
|
|
|
|
.dig?("timestampText", "simpleText")
|
|
|
|
.try { |t| decode_date(t.as_s) } || Time.utc
|
|
|
|
.try { |t| decode_date(t.as_s) } || Time.utc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# View count
|
|
|
|
|
|
|
|
view_count_text = video_details_container.dig?("viewCountText", "simpleText")
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
author = author_fallback.name
|
|
|
|
|
|
|
|
ucid = author_fallback.id
|
|
|
|
|
|
|
|
published = Time.utc
|
|
|
|
|
|
|
|
title = item_contents.dig?("headline", "simpleText").try &.as_s || ""
|
|
|
|
|
|
|
|
end
|
|
|
|
# View count
|
|
|
|
# View count
|
|
|
|
|
|
|
|
|
|
|
|
# View count used to be in the reelWatchEndpoint, but that changed?
|
|
|
|
# View count used to be in the reelWatchEndpoint, but that changed?
|
|
|
|
view_count_text = item_contents.dig?("viewCountText", "simpleText")
|
|
|
|
view_count_text ||= item_contents.dig?("viewCountText", "simpleText")
|
|
|
|
view_count_text ||= video_details_container.dig?("viewCountText", "simpleText")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view_count = view_count_text.try &.as_s.gsub(/\D+/, "").to_i64? || 0_i64
|
|
|
|
view_count = view_count_text.try &.as_s.gsub(/\D+/, "").to_i64? || 0_i64
|
|
|
|
|
|
|
|
|
|
|
|