mirror of
https://github.com/iv-org/invidious.git
synced 2026-07-07 14:16:45 -05:00
Apply remaining review feedback from PR #5237
- Simplify has_unlisted_badge? to one-liner with any? + dig? - Add video_primary_renderer fallback for live_now detection - Simplify early return condition (playability_status != 'UNPLAYABLE')
This commit is contained in:
parent
c5eb4cee9d
commit
b80ac061b9
@ -99,7 +99,7 @@ If you are the administrator, install Invidious Companion: \
|
|||||||
# Stop here if video is not found, or private with no further data.
|
# Stop here if video is not found, or private with no further data.
|
||||||
# For other statuses (UNPLAYABLE, etc.), continue to extract as much
|
# For other statuses (UNPLAYABLE, etc.), continue to extract as much
|
||||||
# data as possible from the /next endpoint.
|
# data as possible from the /next endpoint.
|
||||||
if reason == "Video unavailable" && !{"UNPLAYABLE"}.any?(playability_status)
|
if reason == "Video unavailable" && playability_status != "UNPLAYABLE"
|
||||||
return {
|
return {
|
||||||
"version" => JSON::Any.new(Video::SCHEMA_VERSION.to_i64),
|
"version" => JSON::Any.new(Video::SCHEMA_VERSION.to_i64),
|
||||||
"reason" => JSON::Any.new(reason),
|
"reason" => JSON::Any.new(reason),
|
||||||
@ -282,7 +282,8 @@ If you are the administrator, install Invidious Companion: \
|
|||||||
|
|
||||||
live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow")
|
live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow")
|
||||||
.try &.as_bool
|
.try &.as_bool
|
||||||
live_now ||= video_details.dig?("isLive").try &.as_bool || false
|
live_now ||= video_details.dig?("isLive").try &.as_bool
|
||||||
|
live_now ||= video_primary_renderer.try &.dig?("viewCount", "videoViewCountRenderer", "isLive").try &.as_bool || false
|
||||||
|
|
||||||
post_live_dvr = video_details.dig?("isPostLiveDvr")
|
post_live_dvr = video_details.dig?("isPostLiveDvr")
|
||||||
.try &.as_bool || false
|
.try &.as_bool || false
|
||||||
|
|||||||
@ -69,20 +69,9 @@ rescue ex
|
|||||||
end
|
end
|
||||||
|
|
||||||
def has_unlisted_badge?(badges : JSON::Any?)
|
def has_unlisted_badge?(badges : JSON::Any?)
|
||||||
return false if badges.nil?
|
return badges.try &.as_a.any? { |badge|
|
||||||
|
badge.dig?("metadataBadgeRenderer", "icon", "iconType").try &.as_s == "PRIVACY_UNLISTED"
|
||||||
badges.as_a.each do |badge|
|
} || false
|
||||||
icon_type = badge.dig("metadataBadgeRenderer", "icon", "iconType").as_s
|
|
||||||
|
|
||||||
return true if icon_type == "PRIVACY_UNLISTED"
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
rescue ex
|
|
||||||
LOGGER.debug("Unable to parse badges for unlisted check. Got exception: #{ex.message}")
|
|
||||||
LOGGER.trace("Badges data: #{badges.to_json}")
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# This function extracts SearchVideo items from a Category.
|
# This function extracts SearchVideo items from a Category.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user