diff --git a/lib/yt/models/account.rb b/lib/yt/models/account.rb index af29e293..865d2f1e 100644 --- a/lib/yt/models/account.rb +++ b/lib/yt/models/account.rb @@ -227,6 +227,10 @@ def upload_body(params = {}) def upload_content_type 'video/*' end + + def update_video_params + {} + end end end end diff --git a/lib/yt/models/channel.rb b/lib/yt/models/channel.rb index 95b4d2fa..ea4cabf4 100644 --- a/lib/yt/models/channel.rb +++ b/lib/yt/models/channel.rb @@ -283,7 +283,8 @@ def videos_params # @private # Tells `has_reports` to retrieve the reports from YouTube Analytics API # either as a Channel or as a Content Owner. - # @see https://developers.google.com/youtube/analytics/v1/reports + # @see https://developers.google.com/youtube/analytics/channel_reports + # @see https://developers.google.com/youtube/analytics/content_owner_reports def reports_params {}.tap do |params| if auth.owner_name diff --git a/lib/yt/models/content_owner.rb b/lib/yt/models/content_owner.rb index 87925cab..ba46ebac 100644 --- a/lib/yt/models/content_owner.rb +++ b/lib/yt/models/content_owner.rb @@ -106,6 +106,10 @@ def video_groups_params def playlist_items_params {on_behalf_of_content_owner: @owner_name} end + + def update_video_params + {on_behalf_of_content_owner: @owner_name} + end end end end diff --git a/lib/yt/models/playlist.rb b/lib/yt/models/playlist.rb index 68662d74..5fd4dd70 100644 --- a/lib/yt/models/playlist.rb +++ b/lib/yt/models/playlist.rb @@ -197,7 +197,8 @@ def initialize(options = {}) # @private # Tells `has_reports` to retrieve the reports from YouTube Analytics API # either as a Channel or as a Content Owner. - # @see https://developers.google.com/youtube/analytics/v1/reports + # @see https://developers.google.com/youtube/analytics/channel_reports + # @see https://developers.google.com/youtube/analytics/content_owner_reports def reports_params {}.tap do |params| if auth.owner_name @@ -233,4 +234,4 @@ def playlist_item_params(video_id, params = {}) end end end -end \ No newline at end of file +end diff --git a/lib/yt/models/statistics_set.rb b/lib/yt/models/statistics_set.rb index 8ab7c8fd..dc92caba 100644 --- a/lib/yt/models/statistics_set.rb +++ b/lib/yt/models/statistics_set.rb @@ -6,6 +6,7 @@ module Models # Encapsulates statistics about the resource, such as the number of times # the resource has been viewed or liked. # @see https://developers.google.com/youtube/v3/docs/videos#resource + # @see https://developers.google.com/youtube/v3/docs/channels#resource-representation class StatisticsSet < Base attr_reader :data @@ -23,4 +24,4 @@ def initialize(options = {}) has_attribute :hidden_subscriber_count end end -end \ No newline at end of file +end diff --git a/lib/yt/models/video.rb b/lib/yt/models/video.rb index fc246863..1c8188a3 100644 --- a/lib/yt/models/video.rb +++ b/lib/yt/models/video.rb @@ -621,7 +621,8 @@ def exists? # @private # Tells `has_reports` to retrieve the reports from YouTube Analytics API # either as a Channel or as a Content Owner. - # @see https://developers.google.com/youtube/analytics/v1/reports + # @see https://developers.google.com/youtube/analytics/channel_reports + # @see https://developers.google.com/youtube/analytics/content_owner_reports def reports_params {}.tap do |params| if auth.owner_name @@ -667,6 +668,15 @@ def update_parts {snippet: snippet, status: {keys: status_keys}} end + # For updating video with content owner auth. + # @see https://developers.google.com/youtube/v3/docs/videos/update + def update_params + params = super + params[:params] ||= {} + params[:params].merge! auth.update_video_params + params + end + # NOTE: Another irrational behavior of YouTube API. If you are setting a # video to public/unlisted then you should *not* pass publishAt at any # cost, otherwise the API will fail (since setting publishAt means you diff --git a/spec/requests/as_content_owner/video_spec.rb b/spec/requests/as_content_owner/video_spec.rb index 00dca8ab..b1794393 100644 --- a/spec/requests/as_content_owner/video_spec.rb +++ b/spec/requests/as_content_owner/video_spec.rb @@ -1208,4 +1208,16 @@ end end end + + context 'given a video of a partnered channel' do + let(:id) { 'kocTIjlZwGo' } + + describe 'title can be updated' do + let!(:old_title) { video.title } + let!(:new_title) { old_title.reverse } + before { video.update title: new_title } + it { expect(video.title).to eq(new_title) } + after { video.update title: old_title } + end + end end