Class: YouTube::UploadService
- Inherits:
-
Object
- Object
- YouTube::UploadService
- Defined in:
- app/services/youtube/upload_service.rb
Overview
Uploads a Video to YouTube from Cloudflare Stream or local Dragonfly attachment.
Downloads the MP4 to a temp file, then uploads via the YouTube Data API.
Handles both Cloudflare-hosted and locally-hosted videos.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(account: nil, client: nil) ⇒ UploadService
constructor
A new instance of UploadService.
-
#upload(video, privacy_status: 'private') ⇒ Video
Upload a video to YouTube.
Constructor Details
#initialize(account: nil, client: nil) ⇒ UploadService
Returns a new instance of UploadService.
15 16 17 18 |
# File 'app/services/youtube/upload_service.rb', line 15 def initialize(account: nil, client: nil) @client = client || YouTube::ApiClient.new(account: account) @logger = Rails.logger end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
13 14 15 |
# File 'app/services/youtube/upload_service.rb', line 13 def client @client end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'app/services/youtube/upload_service.rb', line 13 def logger @logger end |
Instance Method Details
#upload(video, privacy_status: 'private') ⇒ Video
Upload a video to YouTube.
24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/youtube/upload_service.rb', line 24 def upload(video, privacy_status: 'private') validate_uploadable!(video) video.update_columns(youtube_upload_status: 'uploading') download_and_upload(video, privacy_status) rescue StandardError video.update_columns(youtube_upload_status: 'failed') raise end |