Class: Yt::Models::Claim

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/models/claim.rb

Overview

Provides methods to interact with YouTube ContentID claims.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Claim

Returns a new instance of Claim


10
11
12
13
14
15
# File 'lib/yt/models/claim.rb', line 10

def initialize(options = {})
  @data = options[:data]
  @id = options[:id]
  @auth = options[:auth]
  @asset = options[:asset] if options[:asset]
end

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth


8
9
10
# File 'lib/yt/models/claim.rb', line 8

def auth
  @auth
end

#claim_historyYt::Collections::ClaimHistories (readonly)

Returns the claim's history.

Returns:


19
# File 'lib/yt/models/claim.rb', line 19

has_one :claim_history

#dataObject (readonly)

Returns the value of attribute data


8
9
10
# File 'lib/yt/models/claim.rb', line 8

def data
  @data
end

Instance Method Details

#active?Boolean

Returns whether the claim is active.

Returns:

  • (Boolean)

    whether the claim is active.


56
57
58
# File 'lib/yt/models/claim.rb', line 56

def active?
  status == 'active'
end

#appealed?Boolean

Returns whether the claim is appealed.

Returns:

  • (Boolean)

    whether the claim is appealed.


61
62
63
# File 'lib/yt/models/claim.rb', line 61

def appealed?
  status == 'appealed'
end

#assetYt::Models::Asset

Returns the asset of the claim

Returns:


123
124
125
# File 'lib/yt/models/claim.rb', line 123

def asset
  @asset
end

#asset_idString

Returns the unique YouTube asset ID that identifies the asset associated with the claim.

Returns:

  • (String)

    the unique YouTube asset ID that identifies the asset associated with the claim.


38
# File 'lib/yt/models/claim.rb', line 38

has_attribute :asset_id

#audio?Boolean

Returns whether the claim covers only the audio.

Returns:

  • (Boolean)

    whether the claim covers only the audio.


103
104
105
# File 'lib/yt/models/claim.rb', line 103

def audio?
  content_type == 'audio'
end

#audiovisual?Boolean

Returns whether the claim covers both audio and video.

Returns:

  • (Boolean)

    whether the claim covers both audio and video.


113
114
115
# File 'lib/yt/models/claim.rb', line 113

def audiovisual?
  content_type == 'audiovisual'
end

#block_outside_ownership?Boolean

Return whether the video should be blocked where not explicitly owned.

Returns:

  • (Boolean)

    whether the claimed video should be blocked anywhere it is not explicitly owned. For example, if you upload a video for an asset that you own in the United States and Canada, and you claim the video with a usage policy to monetize the video everywhere. Since the policy is only applied in countries where you own the asset, YouTube will actually monetize the video in the United States and Canada. By default, the video will still be viewable in other countries even though it will not be monetized in those countries. However, if you set this property to true, then the video will be monetized in the United States and Canada and blocked in all other countries.


146
# File 'lib/yt/models/claim.rb', line 146

has_attribute :block_outside_ownership?, from: :block_outside_ownership

#content_typeString

Returns the audiovisual portion of the claimed content.

Returns:

  • (String)

    the audiovisual portion of the claimed content. Possible values are: 'audio', 'audiovisual', 'video'.


100
# File 'lib/yt/models/claim.rb', line 100

has_attribute :content_type

#created_atTime

Returns the date and time that the claim was created.

Returns:

  • (Time)

    the date and time that the claim was created.


128
# File 'lib/yt/models/claim.rb', line 128

has_attribute :created_at, type: Time, from: :time_created

#deleteBoolean

Note:

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.

Returns:

  • (Boolean)

    whether the claim is inactive.


26
27
28
29
30
# File 'lib/yt/models/claim.rb', line 26

def delete
  body = {status: :inactive}
  do_patch(body: body) {|data| @data = data}
  inactive?
end

#disputed?Boolean

Returns whether the claim is disputed.

Returns:

  • (Boolean)

    whether the claim is disputed.


66
67
68
# File 'lib/yt/models/claim.rb', line 66

def disputed?
  status == 'disputed'
end

#has_unknown_status?Boolean

Returns whether the claim status is unknown.

Returns:

  • (Boolean)

    whether the claim status is unknown.


91
92
93
# File 'lib/yt/models/claim.rb', line 91

def has_unknown_status?
  status == 'unknown'
end

#idString

Returns the ID that YouTube assigns and uses to uniquely identify the claim.

Returns:

  • (String)

    the ID that YouTube assigns and uses to uniquely identify the claim.


34
# File 'lib/yt/models/claim.rb', line 34

has_attribute :id

#inactive?Boolean

Returns whether the claim is inactive.

Returns:

  • (Boolean)

    whether the claim is inactive.


71
72
73
# File 'lib/yt/models/claim.rb', line 71

def inactive?
  status == 'inactive'
end

#match_reference_idString

Returns The unique ID that YouTube uses to identify the reference that generated the match.

Returns:

  • (String)

    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

has_attribute :match_reference_id, from: :match_info do |match_info|
  (match_info || {})['referenceId']
end

#pending?Boolean

Returns whether the claim is pending.

Returns:

  • (Boolean)

    whether the claim is pending.


76
77
78
# File 'lib/yt/models/claim.rb', line 76

def pending?
  status == 'pending'
end

#potential?Boolean

Returns whether the claim is potential.

Returns:

  • (Boolean)

    whether the claim is potential.


81
82
83
# File 'lib/yt/models/claim.rb', line 81

def potential?
  status == 'potential'
end

#sourceString

Returns the source of the claim

Returns:

  • (String)

    the source of the claim


118
119
120
# File 'lib/yt/models/claim.rb', line 118

def source
  @data.fetch('origin', {})['source']
end

#statusString

Note:

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.

Returns:

  • (String)

    the claim’s status. Possible values are: 'active', 'appealed', 'disputed', 'inactive', 'pending', 'potential', 'takedown', 'unknown'.


53
# File 'lib/yt/models/claim.rb', line 53

has_attribute :status

#takedown?Boolean

Returns whether the claim is takedown.

Returns:

  • (Boolean)

    whether the claim is takedown.


86
87
88
# File 'lib/yt/models/claim.rb', line 86

def takedown?
  status == 'takedown'
end

#third_party?Boolean

Returns whether a third party created the claim.

Returns:

  • (Boolean)

    whether a third party created the claim.


131
132
133
# File 'lib/yt/models/claim.rb', line 131

has_attribute :third_party?, from: :third_party_claim do |value|
  value == true
end

#video?Boolean

Returns whether the claim covers only the video.

Returns:

  • (Boolean)

    whether the claim covers only the video.


108
109
110
# File 'lib/yt/models/claim.rb', line 108

def video?
  content_type == 'video'
end

#video_idString

Returns the unique YouTube video ID that identifies the video associated with the claim.

Returns:

  • (String)

    the unique YouTube video ID that identifies the video associated with the claim.


42
# File 'lib/yt/models/claim.rb', line 42

has_attribute :video_id