Class: Yt::Models::Claim
Overview
Provides methods to interact with YouTube ContentID claims.
Constant Summary collapse
- STATUSES =
Status
%q(active appealed disputed inactive pending potential takedown unknown)
- CONTENT_TYPES =
Content Type
%q(audio video audiovisual)
Instance Method Summary collapse
-
#active? ⇒ Boolean
Whether the claim is active.
-
#appealed? ⇒ Boolean
Whether the claim is appealed.
-
#asset_id ⇒ String
The unique YouTube asset ID that identifies the asset associated with the claim.
-
#audio? ⇒ Boolean
Whether the covers the audio of the content.
-
#audiovisual? ⇒ Boolean
Whether the covers the audiovisual of the content.
-
#block_outside_ownership? ⇒ Boolean
Return whether the video should be blocked where not explicitly owned.
-
#content_type ⇒ String
Whether the claim covers the audio, video, or audiovisual portion of the claimed content.
-
#created_at ⇒ Time
The date and time that the claim was created.
-
#delete ⇒ Boolean
Soft-deletes the claim.
-
#disputed? ⇒ Boolean
Whether the claim is disputed.
-
#has_unknown_status? ⇒ Boolean
Whether the claim status is unknown.
-
#id ⇒ String
The ID that YouTube assigns and uses to uniquely identify the claim.
-
#inactive? ⇒ Boolean
Whether the claim is inactive.
-
#initialize(options = {}) ⇒ Claim
constructor
A new instance of Claim.
-
#match_reference_id ⇒ String
The unique ID that YouTube uses to identify the reference that generated the match.
- #patch_params ⇒ Object
-
#pending? ⇒ Boolean
Whether the claim is pending.
-
#potential? ⇒ Boolean
Whether the claim is potential.
-
#status ⇒ String
The claim’s status.
-
#takedown? ⇒ Boolean
Whether the claim is takedown.
-
#third_party? ⇒ Boolean
Whether a third party created the claim.
-
#video? ⇒ Boolean
Whether the covers the video of the content.
-
#video_id ⇒ String
The unique YouTube video ID that identifies the video associated with the claim.
Methods included from Associations::HasReports
Methods included from Associations::HasViewerPercentages
Methods included from Associations::HasOne
Methods included from Associations::HasMany
Methods included from Associations::HasAuthentication
Constructor Details
#initialize(options = {}) ⇒ Claim
Returns a new instance of Claim.
8 9 10 11 12 |
# File 'lib/yt/models/claim.rb', line 8 def initialize( = {}) @data = [:data] @id = [:id] @auth = [:auth] end |
Instance Method Details
#active? ⇒ Boolean
Returns whether the claim is active.
58 59 60 |
# File 'lib/yt/models/claim.rb', line 58 def active? status == 'active' end |
#appealed? ⇒ Boolean
Returns whether the claim is appealed.
63 64 65 |
# File 'lib/yt/models/claim.rb', line 63 def appealed? status == 'appealed' end |
#asset_id ⇒ String
Returns the unique YouTube asset ID that identifies the asset associated with the claim.
33 34 35 |
# File 'lib/yt/models/claim.rb', line 33 def asset_id @asset_id ||= @data["assetId"] end |
#audio? ⇒ Boolean
Returns whether the covers the audio of the content.
109 110 111 |
# File 'lib/yt/models/claim.rb', line 109 def audio? content_type == 'audio' end |
#audiovisual? ⇒ Boolean
Returns whether the covers the audiovisual of the content.
119 120 121 |
# File 'lib/yt/models/claim.rb', line 119 def audiovisual? content_type == 'audiovisual' end |
#block_outside_ownership? ⇒ Boolean
Return whether the video should be blocked where not explicitly owned.
144 145 146 |
# File 'lib/yt/models/claim.rb', line 144 def block_outside_ownership? @block_outside_ownership ||= @data["blockOutsideOwnership"] end |
#content_type ⇒ String
Returns whether the claim covers the audio, video, or audiovisual portion of the claimed content. Valid values are: audio, audiovisual, video.
104 105 106 |
# File 'lib/yt/models/claim.rb', line 104 def content_type @content_type ||= @data["contentType"] end |
#created_at ⇒ Time
Returns the date and time that the claim was created.
124 125 126 |
# File 'lib/yt/models/claim.rb', line 124 def created_at @created_at ||= Time.parse @data["timeCreated"] end |
#delete ⇒ Boolean
YouTube API does not provide a delete
method for the Asset resource, but only an update
method. Updating the status
of a Asset to “inactive” can be considered a soft-deletion.
Soft-deletes the claim.
19 20 21 22 23 |
# File 'lib/yt/models/claim.rb', line 19 def delete body = {status: :inactive} do_patch(body: body) {|data| @data = data} inactive? end |
#disputed? ⇒ Boolean
Returns whether the claim is disputed.
68 69 70 |
# File 'lib/yt/models/claim.rb', line 68 def disputed? status == 'disputed' end |
#has_unknown_status? ⇒ Boolean
Returns whether the claim status is unknown.
93 94 95 |
# File 'lib/yt/models/claim.rb', line 93 def has_unknown_status? status == 'unknown' end |
#id ⇒ String
Returns the ID that YouTube assigns and uses to uniquely identify the claim.
27 28 29 |
# File 'lib/yt/models/claim.rb', line 27 def id @id ||= @data['id'] end |
#inactive? ⇒ Boolean
Returns whether the claim is inactive.
73 74 75 |
# File 'lib/yt/models/claim.rb', line 73 def inactive? status == 'inactive' end |
#match_reference_id ⇒ String
Returns The unique ID that YouTube uses to identify the reference that generated the match.
150 151 152 |
# File 'lib/yt/models/claim.rb', line 150 def match_reference_id @match_reference_id ||= @data.fetch('matchInfo', {})['referenceId'] end |
#patch_params ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/yt/models/claim.rb', line 155 def patch_params super.tap do |params| params[:expected_response] = Net::HTTPOK params[:path] = "/youtube/partner/v1/claims/#{id}" params[:params] = {on_behalf_of_content_owner: @auth.owner_name} end end |
#pending? ⇒ Boolean
Returns whether the claim is pending.
78 79 80 |
# File 'lib/yt/models/claim.rb', line 78 def pending? status == 'pending' end |
#potential? ⇒ Boolean
Returns whether the claim is potential.
83 84 85 |
# File 'lib/yt/models/claim.rb', line 83 def potential? status == 'potential' end |
#status ⇒ String
When updating a claim, you can update its status from active to inactive to effectively release the claim, but the API does not support other updates to a claim’s status.
Returns the claim’s status. Valid values are: active, appealed, disputed, inactive, pending, potential, takedown, unknown.
53 54 55 |
# File 'lib/yt/models/claim.rb', line 53 def status @status ||= @data["status"] end |
#takedown? ⇒ Boolean
Returns whether the claim is takedown.
88 89 90 |
# File 'lib/yt/models/claim.rb', line 88 def takedown? status == 'takedown' end |
#third_party? ⇒ Boolean
Returns whether a third party created the claim.
129 130 131 |
# File 'lib/yt/models/claim.rb', line 129 def third_party? @third_party_claim ||= @data['thirdPartyClaim'] == true end |
#video? ⇒ Boolean
Returns whether the covers the video of the content.
114 115 116 |
# File 'lib/yt/models/claim.rb', line 114 def video? content_type == 'video' end |
#video_id ⇒ String
Returns the unique YouTube video ID that identifies the video associated with the claim.
39 40 41 |
# File 'lib/yt/models/claim.rb', line 39 def video_id @video_id ||= @data["videoId"] end |