Class: YouTube::RemoteCaptionsStatus
- Inherits:
-
Object
- Object
- YouTube::RemoteCaptionsStatus
- Defined in:
- app/services/youtube/remote_captions_status.rb
Overview
Reads caption track metadata from YouTube via captions.list (same API used before push).
Only works when OAuth is healthy and the connected channel can manage the video.
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(video, client: nil, oauth_service: nil) ⇒ RemoteCaptionsStatus
constructor
A new instance of RemoteCaptionsStatus.
- #summary ⇒ Object
Constructor Details
#initialize(video, client: nil, oauth_service: nil) ⇒ RemoteCaptionsStatus
Returns a new instance of RemoteCaptionsStatus.
29 30 31 32 33 |
# File 'app/services/youtube/remote_captions_status.rb', line 29 def initialize(video, client: nil, oauth_service: nil) @video = video @client = client @oauth_service = oauth_service end |
Class Method Details
.summary(video, client: nil, oauth_service: nil) ⇒ Object
25 26 27 |
# File 'app/services/youtube/remote_captions_status.rb', line 25 def self.summary(video, client: nil, oauth_service: nil) new(video, client: client, oauth_service: oauth_service).summary end |
Instance Method Details
#summary ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/youtube/remote_captions_status.rb', line 35 def summary return Summary.new(state: :skipped, tracks: [], error_message: nil) if @video.youtube_id.blank? return Summary.new(state: :skipped, tracks: [], error_message: nil) unless oauth_healthy? items = api_client.list_captions(@video.youtube_id) tracks = items.map { |c| build_track(c) } Summary.new(state: :loaded, tracks: tracks, error_message: nil) rescue OauthService::TokenRefreshError => e Summary.new(state: :failed, tracks: [], error_message: e.) rescue ApiClient::ApiError => e Summary.new(state: :failed, tracks: [], error_message: e.) end |