Abilita l'embed YouTube sulle dirette e tiene la copia locale se il VOD non è incorporabile.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -46,10 +46,11 @@ module Recordings
|
||||
return Result.new(status: :pending, message: "vod_not_ready")
|
||||
end
|
||||
|
||||
info = enable_embed_if_needed!(info)
|
||||
apply_verified!(info)
|
||||
Rails.logger.info(
|
||||
"[Recordings::VerifyYoutubeReplay] ok recording=#{@recording.id} " \
|
||||
"youtube_video_id=#{info.video_id}"
|
||||
"youtube_video_id=#{info.video_id} embeddable=#{info.embeddable}"
|
||||
)
|
||||
Result.new(status: :ok, message: "verified")
|
||||
rescue Youtube::VodStatus::Error => e
|
||||
@@ -68,6 +69,7 @@ module Recordings
|
||||
"thumbnail_url" => info.thumbnail_url,
|
||||
"privacy_status" => info.privacy_status,
|
||||
"upload_status" => info.upload_status,
|
||||
"embeddable" => info.embeddable,
|
||||
"verified_via" => "live_broadcast"
|
||||
).compact
|
||||
|
||||
@@ -82,5 +84,23 @@ module Recordings
|
||||
|
||||
@recording.update!(attrs)
|
||||
end
|
||||
|
||||
def enable_embed_if_needed!(info)
|
||||
return info if info.embeddable != false
|
||||
return info if info.video_id.to_s.start_with?("mock_")
|
||||
|
||||
session = @recording.stream_session
|
||||
Youtube::BroadcastService.new(session.match.team).enable_video_embed!(
|
||||
info.video_id,
|
||||
privacy_status: info.privacy_status
|
||||
)
|
||||
refreshed = Youtube::VodStatus.new(@recording.team, channel: "team").fetch(info.video_id)
|
||||
refreshed.ready ? refreshed : info
|
||||
rescue Youtube::BroadcastService::Error, Youtube::VodStatus::Error => e
|
||||
Rails.logger.warn(
|
||||
"[Recordings::VerifyYoutubeReplay] enable_embed recording=#{@recording.id}: #{e.message}"
|
||||
)
|
||||
info
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user