videos: handle different JSON structs being present in cache

This commit is contained in:
Samantaz Fox
2022-10-03 21:58:52 +02:00
parent db91d3af66
commit 2acff70811
2 changed files with 21 additions and 2 deletions

View File

@@ -71,7 +71,8 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
# Stop here if video is not a scheduled livestream
if playability_status != "LIVE_STREAM_OFFLINE"
return {
"reason" => JSON::Any.new(reason),
"version" => JSON::Any.new(Video::SCHEMA_VERSION.to_i64),
"reason" => JSON::Any.new(reason),
}
end
elsif video_id != player_response.dig("videoDetails", "videoId")
@@ -121,6 +122,9 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
params[f] = player_response[f] if player_response[f]?
end
# Data structure version, for cache control
params["version"] = JSON::Any.new(Video::SCHEMA_VERSION.to_i64)
return params
end