Messaggi chiari per errori YouTube API in creazione diretta.
Include guida su liveStreamingNotEnabled e token non validi. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,7 +3,7 @@ module Admin
|
|||||||
before_action :set_club, only: %i[show grant_comped revoke_comped]
|
before_action :set_club, only: %i[show grant_comped revoke_comped]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@clubs = Club.includes(:subscription, :teams, subscription: :plan, subscription: :admin_comped_by)
|
@clubs = Club.includes(:teams, subscription: %i[plan admin_comped_by])
|
||||||
.order(:name)
|
.order(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module Youtube
|
|||||||
rtmp_url: stream_result.cdn.ingestion_info.ingestion_address
|
rtmp_url: stream_result.cdn.ingestion_info.ingestion_address
|
||||||
}
|
}
|
||||||
rescue Google::Apis::Error => e
|
rescue Google::Apis::Error => e
|
||||||
raise Error, e.message
|
raise Error, friendly_api_error(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
def complete_broadcast!(broadcast_id)
|
def complete_broadcast!(broadcast_id)
|
||||||
@@ -86,5 +86,13 @@ module Youtube
|
|||||||
def authorized_client
|
def authorized_client
|
||||||
OauthRefresh.new(@credential).apply!(Google::Apis::YoutubeV3::YouTubeService.new)
|
OauthRefresh.new(@credential).apply!(Google::Apis::YoutubeV3::YouTubeService.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def friendly_api_error(error)
|
||||||
|
msg = error.message.to_s
|
||||||
|
return "Il canale YouTube non ha la diretta attiva. Apri YouTube Studio con l’account del canale Match Live TV, abilita la live (verifica telefono se richiesto) e riprova." if msg.include?("liveStreamingNotEnabled")
|
||||||
|
return "Credenziali YouTube non valide. Ricollega il canale dalla sezione Admin → YouTube." if msg.match?(/Unauthorized|invalid_grant/i)
|
||||||
|
|
||||||
|
msg
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user