Skip to content

Commit

Permalink
Merge 6f014d3 into b2ea040
Browse files Browse the repository at this point in the history
  • Loading branch information
kangkyu committed Feb 7, 2020
2 parents b2ea040 + 6f014d3 commit 62baecd
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/yt/models/account.rb
Expand Up @@ -227,6 +227,10 @@ def upload_body(params = {})
def upload_content_type
'video/*'
end

def update_video_params
{}
end
end
end
end
3 changes: 2 additions & 1 deletion lib/yt/models/channel.rb
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/yt/models/content_owner.rb
Expand Up @@ -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
5 changes: 3 additions & 2 deletions lib/yt/models/playlist.rb
Expand Up @@ -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
Expand Down Expand Up @@ -233,4 +234,4 @@ def playlist_item_params(video_id, params = {})
end
end
end
end
end
3 changes: 2 additions & 1 deletion lib/yt/models/statistics_set.rb
Expand Up @@ -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

Expand All @@ -23,4 +24,4 @@ def initialize(options = {})
has_attribute :hidden_subscriber_count
end
end
end
end
12 changes: 11 additions & 1 deletion lib/yt/models/video.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spec/requests/as_content_owner/video_spec.rb
Expand Up @@ -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

0 comments on commit 62baecd

Please sign in to comment.