Class: Yt::Models::Status

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

Overview

Contains information about the status of a resource. The details of the status are different for the different types of resources.

Resources with a status are: channels, playlists, playlist items and videos.

Constant Summary collapse

PRIVACY_STATUSES =

Privacy status

%q(private public unlisted)

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Status

Returns a new instance of Status.



15
16
17
# File 'lib/yt/models/status.rb', line 15

def initialize(options = {})
  @data = options[:data]
end

Instance Method Details

#aborted?Boolean?

Returns whether a video upload failed because the upload was aborted.

Returns:

  • (Boolean)

    if the resource is a video, whether the uploading process was aborted.

  • (nil)

    if the resource is not a video or upload has not failed.



154
155
156
# File 'lib/yt/models/status.rb', line 154

def aborted?
  failure_reason == 'uploadAborted' if video?
end

#belongs_to_closed_account?Boolean?

Returns whether a video was rejected because the account was closed.

Returns:

  • (Boolean)

    if the resource is a rejected video, whether the account associated with the video has been closed.

  • (nil)

    if the resource is not a rejected video.



232
233
234
# File 'lib/yt/models/status.rb', line 232

def belongs_to_closed_account?
  rejection_reason == 'uploaderAccountClosed' if video?
end

#belongs_to_suspended_account?Boolean?

Returns whether a video was rejected because the account was suspended.

Returns:

  • (Boolean)

    if the resource is a rejected video, whether the account associated with the video has been suspended.

  • (nil)

    if the resource is not a rejected video.



240
241
242
# File 'lib/yt/models/status.rb', line 240

def belongs_to_suspended_account?
  rejection_reason == 'uploaderAccountSuspended' if video?
end

#claimed?Boolean?

Returns whether a video was rejected because it was claimed.

Returns:

  • (Boolean)

    if the resource is a rejected video, whether the video was claimed by a different account.

  • (nil)

    if the resource is not a rejected video.



174
175
176
# File 'lib/yt/models/status.rb', line 174

def claimed?
  rejection_reason == 'claim' if video?
end

#deleted?Boolean?

Returns whether an uploaded video was deleted.

Returns:

  • (Boolean)

    if the resource is a video, whether the uploaded video was deleted by the user.

  • (nil)

    if the resource is not a video.



59
60
61
# File 'lib/yt/models/status.rb', line 59

def deleted?
  upload_status == 'deleted' if video?
end

#duplicate?Boolean?

Returns whether a video was rejected because it is a duplicate.

Returns:

  • (Boolean)

    if the resource is a rejected video, whether the video is a duplicate of another uploaded video.

  • (nil)

    if the resource is not a rejected video.



190
191
192
# File 'lib/yt/models/status.rb', line 190

def duplicate?
  rejection_reason == 'duplicate' if video?
end

#embeddable?Boolean? Also known as: embeddable

Returns whether the video can be embedded on another website.

Returns:

  • (Boolean)

    if the resource is a video, whether it can be embedded on another website.

  • (nil)

    if the resource is not a video.



298
299
300
# File 'lib/yt/models/status.rb', line 298

def embeddable?
  @embeddable ||= @data['embeddable']
end

#empty?Boolean?

Returns whether a video upload failed because the file was empty.

Returns:

  • (Boolean)

    if the resource is a video, whether the video file is empty.

  • (nil)

    if the resource is not a video or upload has not failed.



129
130
131
# File 'lib/yt/models/status.rb', line 129

def empty?
  failure_reason == 'emptyFile' if video?
end

#failed?Boolean?

Returns whether a video failed to upload. If true, the reason why the video upload failed can be obtained with failure_reason.

Returns:

  • (Boolean)

    if the resource is a video, whether the video failed to upload.

  • (nil)

    if the resource is not a video.



68
69
70
# File 'lib/yt/models/status.rb', line 68

def failed?
  upload_status == 'failed' if video?
end

#failure_reasonString?

Returns the reason why a video failed to upload.

Returns:

  • (String)

    if resource is a video with a ‘failed’ upload status, the reason why the video failed to upload. Valid values are: codec, conversion, emptyFile, invalidFile, tooSmall, uploadAborted.

  • (nil)

    if the resource is not a video or upload has not failed.



104
105
106
# File 'lib/yt/models/status.rb', line 104

def failure_reason
  @failure_reason ||= @data['failureReason']
end

#has_failed_conversion?Boolean?

Returns whether YouTube was unable to convert an uploaded video.

Returns:

  • (Boolean)

    if the resource is a video, whether YouTube was unable to convert the video.

  • (nil)

    if the resource is not a video or upload has not failed.



121
122
123
# File 'lib/yt/models/status.rb', line 121

def has_failed_conversion?
  failure_reason == 'conversion' if video?
end

#has_public_stats_viewable?Boolean? Also known as: public_stats_viewable

Returns whether the video statistics are publicly viewable.

Returns:

  • (Boolean)

    if the resource is a video, whether the extended video statistics on the video’s watch page are publicly viewable. By default, those statistics are viewable, and statistics like a video’s viewcount and ratings will still be publicly visible even if this property’s value is set to false.

  • (nil)

    if the resource is not a video.



312
313
314
# File 'lib/yt/models/status.rb', line 312

def has_public_stats_viewable?
  @public_stats_viewable ||= @data['publicStatsViewable']
end

#inappropriate?Boolean?

Returns whether a video was rejected because of inappropriate content.

Returns:

  • (Boolean)

    if the resource is a rejected video, whether the video contains inappropriate content.

  • (nil)

    if the resource is not a rejected video.



198
199
200
# File 'lib/yt/models/status.rb', line 198

def inappropriate?
  rejection_reason == 'inappropriate' if video?
end

#infringes_copyright?Boolean?

Returns whether a video was rejected because of copyright infringement.

Returns:

  • (Boolean)

    if the resource is a rejected video, whether the video commits a copyright infringement.

  • (nil)

    if the resource is not a rejected video.



182
183
184
# File 'lib/yt/models/status.rb', line 182

def infringes_copyright?
  rejection_reason == 'copyright' if video?
end

#infringes_trademark?Boolean?

Returns whether a video was rejected because of trademark infringement.

Returns:

  • (Boolean)

    if the resource is a rejected video, whether the video commits a trademark infringement.

  • (nil)

    if the resource is not a rejected video.

See Also:



224
225
226
# File 'lib/yt/models/status.rb', line 224

def infringes_trademark?
  rejection_reason == 'trademark' if video?
end

#invalid?Boolean?

Returns whether a video upload failed because of the file format.

Returns:

  • (Boolean)

    if the resource is a video, whether the video uses a file format not supported by YouTube.

  • (nil)

    if the resource is not a video or upload has not failed.

See Also:



138
139
140
# File 'lib/yt/models/status.rb', line 138

def invalid?
  failure_reason == 'invalidFile' if video?
end

#licenseString?

Returns the video’s license.

Returns:

  • (String)

    if resource is a video, its license. Valid values are: creativeCommon, youtube.

  • (nil)

    if the resource is not a video.



270
271
272
# File 'lib/yt/models/status.rb', line 270

def license
  @license ||= @data['license']
end

#licensed_as_creative_commons?Boolean?

Returns whether the video uses a Creative Commons license.

Returns:

  • (Boolean)

    if the resource is a video, whether it uses a Creative Commons license.

  • (nil)

    if the resource is not a video.

See Also:



279
280
281
# File 'lib/yt/models/status.rb', line 279

def licensed_as_creative_commons?
  license == 'creativeCommon' if video?
end

#licensed_as_standard_youtube?Boolean?

Returns whether the video uses the Standard YouTube license.

Returns:

  • (Boolean)

    if the resource is a video, whether it uses the Standard YouTube license.

  • (nil)

    if the resource is not a video.

See Also:



288
289
290
# File 'lib/yt/models/status.rb', line 288

def licensed_as_standard_youtube?
  license == 'youtube' if video?
end

#privacy_statusString

Returns the privacy status of the resource. Valid values are: private, public, unlisted.

Returns:

  • (String)

    the privacy status of the resource. Valid values are: private, public, unlisted.



25
26
27
# File 'lib/yt/models/status.rb', line 25

def privacy_status
  @privacy_status ||= @data['privacyStatus']
end

#private?Boolean

Returns whether the resource is private.

Returns:

  • (Boolean)

    whether the resource is private.



35
36
37
# File 'lib/yt/models/status.rb', line 35

def private?
  privacy_status == 'private'
end

#processed?Boolean?

Returns whether an uploaded video is being processed by YouTube.

Returns:

  • (Boolean)

    if the resource is a video, whether the uploaded video is being processed by YouTube.

  • (nil)

    if the resource is not a video.



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

def processed?
  upload_status == 'processed' if video?
end

#public?Boolean

Returns whether the resource is public.

Returns:

  • (Boolean)

    whether the resource is public.



30
31
32
# File 'lib/yt/models/status.rb', line 30

def public?
  privacy_status == 'public'
end

#rejected?Boolean?

Returns whether the video was rejected by YouTube. If true, the reason why the video was rejected can be obtained with rejection_reason.

Returns:

  • (Boolean)

    if the resource is a video, whether the video was rejected by YouTube.

  • (nil)

    if the resource is not a video.



85
86
87
# File 'lib/yt/models/status.rb', line 85

def rejected?
  upload_status == 'rejected' if video?
end

#rejection_reasonString?

Returns the reason why a video was rejected by YouTube.

Returns:

  • (String)

    if resource is a video with a ‘rejected’ upload status, the reason why the video was rejected. Valid values are: claim, copyright, duplicate, inappropriate, length, termsOfUse, trademark, uploaderAccountClosed, uploaderAccountSuspended.

  • (nil)

    if the resource is not a rejected video.



166
167
168
# File 'lib/yt/models/status.rb', line 166

def rejection_reason
  @rejection_reason ||= @data['rejectionReason']
end

#scheduled?Boolean?

Returns whether the video is scheduled to be published.

Returns:

  • (Boolean)

    if the resource is a video, whether it is currently private and is scheduled to become public in the future.

  • (nil)

    if the resource is not a video.



260
261
262
# File 'lib/yt/models/status.rb', line 260

def scheduled?
  private? && @data['publishAt'] if video?
end

#scheduled_atTime? Also known as: publish_at

Returns the date and time when a video is scheduled to be published.

Returns:

  • (Time)

    if resource is a private video scheduled to be published, the date and time when the video is scheduled to publish.

  • (nil)

    if the resource is not a private video scheduled to be published.



251
252
253
# File 'lib/yt/models/status.rb', line 251

def scheduled_at
  @scheduled_at ||= Yt::Timestamp.parse @data['publishAt'] if scheduled?
end

#too_long?Boolean?

Returns whether a video was rejected because it is too long.

Returns:

  • (Boolean)

    if the resource is a rejected video, whether the video exceeds the maximum duration.

  • (nil)

    if the resource is not a rejected video.

See Also:



207
208
209
# File 'lib/yt/models/status.rb', line 207

def too_long?
  rejection_reason == 'length' if video?
end

#too_small?Boolean?

Returns whether a video upload failed because the file was too small.

Returns:

  • (Boolean)

    if the resource is a video, whether the video file is too small for YouTube.

  • (nil)

    if the resource is not a video or upload has not failed.



146
147
148
# File 'lib/yt/models/status.rb', line 146

def too_small?
  failure_reason == 'tooSmall' if video?
end

#unlisted?Boolean

Returns whether the resource is unlisted.

Returns:

  • (Boolean)

    whether the resource is unlisted.



40
41
42
# File 'lib/yt/models/status.rb', line 40

def unlisted?
  privacy_status == 'unlisted'
end

#upload_statusString?

Returns the upload status of a video.

Returns:

  • (String)

    if the resource is a video, the status of the uploaded video. Valid values are: deleted, failed, processed, rejected, uploaded.

  • (nil)

    if the resource is not a video.



51
52
53
# File 'lib/yt/models/status.rb', line 51

def upload_status
  @upload_status ||= @data['uploadStatus']
end

#uploaded?Boolean?

Returns whether a video was successfully uploaded to YouTube.

Returns:

  • (Boolean)

    if the resource is a video, whether the video was successfully uploaded.

  • (nil)

    if the resource is not a video.



93
94
95
# File 'lib/yt/models/status.rb', line 93

def uploaded?
  upload_status == 'uploaded' if video?
end

#uses_unsupported_codec?Boolean?

Returns whether a video upload failed because of the codec.

Returns:

  • (Boolean)

    if the resource is a video, whether the video uses a codec not supported by YouTube.

  • (nil)

    if the resource is not a video or upload has not failed.

See Also:



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

def uses_unsupported_codec?
  failure_reason == 'codec' if video?
end

#violates_terms_of_use?Boolean?

Returns whether a video was rejected because it violates terms of use.

Returns:

  • (Boolean)

    if the resource is a rejected video, whether the video commits a terms of use violation.

  • (nil)

    if the resource is not a rejected video.



215
216
217
# File 'lib/yt/models/status.rb', line 215

def violates_terms_of_use?
  rejection_reason == 'termsOfUse' if video?
end