Class: Yt::Models::Video
- Defined in:
- lib/yt/models/video.rb
Overview
Provides methods to interact with YouTube videos.
Constant Summary
Constants inherited from Resource
Resource::CHANNEL_PATTERNS, Resource::PLAYLIST_PATTERNS, Resource::VIDEO_PATTERNS
Instance Attribute Summary collapse
-
#actual_end_time ⇒ Time?
readonly
The time when a live broadcast ended.
-
#actual_start_time ⇒ Time?
readonly
The time when a live broadcast started.
-
#ad_formats ⇒ Array<String>
readonly
The list of ad formats that the video is allowed to show.
-
#annotations ⇒ Yt::Collections::Annotations
readonly
The video’s annotations.
-
#channel_id ⇒ String
readonly
The ID of the channel that the video belongs to.
-
#channel_title ⇒ String
readonly
The title of the channel that the video belongs to.
- #claim ⇒ Object readonly
-
#comment_count ⇒ Integer
readonly
The number of comments for the video.
-
#comments(options = {}) ⇒ Hash<Date, Integer>, ...
readonly
Returns the comments grouped by the given dimension.
-
#concurrent_viewers ⇒ Integer?
readonly
The number of current viewers of a live broadcast.
-
#container ⇒ String
readonly
The video container of the uploaded file.
-
#description ⇒ String
readonly
The video’s description.
-
#dislike_count ⇒ Integer
readonly
The number of users who disliked the video.
-
#duration ⇒ String
readonly
The length of the video as an ISO 8601 time, HH:MM:SS.
-
#embed_html ⇒ String
readonly
The HTML code of an <iframe> tag that embeds a player that will play the video.
-
#favorite_count ⇒ Integer
readonly
The number of users who marked the video as favorite.
-
#file_name ⇒ String
readonly
The name of the uploaded file.
-
#file_size ⇒ Integer
readonly
The size of the uploaded file (in bytes).
-
#file_type ⇒ String
readonly
The type of file uploaded.
-
#license ⇒ String
readonly
The video’s license.
-
#like_count ⇒ Integer
readonly
The number of users who liked the video.
-
#live_broadcast_content ⇒ String
readonly
The type of live broadcast that the video contains.
-
#published_at ⇒ Time
readonly
The date and time that the video was published.
-
#scheduled_end_time ⇒ Time?
readonly
The time when a live broadcast is scheduled to end.
-
#scheduled_start_time ⇒ Time?
readonly
The time when a live broadcast is scheduled to start.
-
#title ⇒ String
readonly
The video’s title.
-
#view_count ⇒ Integer
readonly
The number of times the video has been viewed.
Attributes inherited from Resource
Instance Method Summary collapse
-
#aborted? ⇒ Boolean
Whether the video failed to upload to YouTube because the uploading process was aborted.
-
#ad_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the ad_impressions grouped by the given dimension.
-
#age_restricted? ⇒ Boolean
Whether the video is identified by YouTube as age-restricted content.
-
#annotation_click_through_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_click_through_rate grouped by the given dimension.
-
#annotation_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the annotation_clicks grouped by the given dimension.
-
#annotation_close_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_close_rate grouped by the given dimension.
-
#average_view_duration(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the average_view_duration grouped by the given dimension.
-
#average_view_percentage(options = {}) ⇒ Hash<Date, Float>, ...
Returns the average_view_percentage grouped by the given dimension.
-
#belongs_to_closed_account? ⇒ Boolean
Whether the video was rejected by YouTube because the account that uploaded the video has been closed.
-
#belongs_to_suspended_account? ⇒ Boolean
Whether the video was rejected by YouTube because the account that uploaded the video has been suspended.
-
#captioned? ⇒ Boolean
Whether captions are available for the video.
-
#card_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_click_rate grouped by the given dimension.
-
#card_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_clicks grouped by the given dimension.
-
#card_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_impressions grouped by the given dimension.
-
#card_teaser_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_teaser_click_rate grouped by the given dimension.
-
#card_teaser_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_clicks grouped by the given dimension.
-
#card_teaser_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_impressions grouped by the given dimension.
-
#category_id ⇒ String
ID of the YouTube category associated with the video.
-
#category_title ⇒ String
The video category’s title.
-
#channel_url ⇒ <String>
The URL of the channel that the video belongs to.
-
#claimed? ⇒ Boolean
Whether the video was rejected by YouTube because the video was claimed by a different account.
-
#delete(options = {}) ⇒ Boolean
Deletes the video on behalf of the authenticated account.
-
#deleted? ⇒ Boolean
Whether the video was deleted by the user.
-
#dislike ⇒ Boolean
Dislikes the video on behalf of the authenticated account.
-
#dislikes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the dislikes grouped by the given dimension.
-
#duplicate? ⇒ Boolean
Whether the video was rejected by YouTube because the video is a duplicate of another video.
-
#embeddable? ⇒ Boolean
Whether the video can be embedded on other websites.
-
#empty? ⇒ Boolean
Whether the video failed to upload to YouTube because the video file is empty.
-
#estimated_minutes_watched(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the estimated_minutes_watched grouped by the given dimension.
-
#estimated_revenue(options = {}) ⇒ Hash<Date, Float>, ...
Returns the estimated_revenue grouped by the given dimension.
-
#failed? ⇒ Boolean
Whether the video failed to upload.
-
#has_failed_conversion? ⇒ Boolean
Whether the video failed to upload to YouTube because YouTube was unable to convert the video.
-
#has_public_stats_viewable? ⇒ Boolean
Returns whether the video statistics are publicly viewable.
-
#hd? ⇒ Boolean
Whether the video is available in high definition.
-
#inappropriate? ⇒ Boolean
Whether the video was rejected by YouTube because the video contains inappropriate content.
-
#infringes_copyright? ⇒ Boolean
Whether the video was rejected by YouTube because the video commits a copyright infringement.
-
#infringes_trademark? ⇒ Boolean
Whether the video was rejected by YouTube because the video infringes a trademark.
-
#invalid? ⇒ Boolean
Whether the video failed to upload to YouTube because the video uses an unsupported file format.
-
#licensed? ⇒ Boolean
Whether the video represents licensed content, which means that the content has been claimed by a YouTube content partner.
-
#licensed_as_creative_commons? ⇒ Boolean
Whether the video uses a Creative Commons license.
-
#licensed_as_standard_youtube? ⇒ Boolean
Whether the video uses the Standard YouTube license.
-
#like ⇒ Boolean
Likes the video on behalf of the authenticated account.
-
#liked? ⇒ Boolean
Whether the authenticated account likes the video.
-
#likes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the likes grouped by the given dimension.
-
#made_for_kids? ⇒ Boolean
@return [Boolean, nil] This value indicates whether the video is designated as child-directed, and it contains the current “made for kids” status of the video.
-
#monetized_playbacks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the monetized_playbacks grouped by the given dimension.
-
#playback_based_cpm(options = {}) ⇒ Hash<Date, Float>, ...
Returns the playback_based_cpm grouped by the given dimension.
-
#processed? ⇒ Boolean
Whether the video has been fully processed by YouTube.
-
#rejected? ⇒ Boolean
Whether the video was rejected by YouTube.
-
#reports(options = {}) ⇒ Hash<Symbol, Hash>
Returns the reports for the given metrics grouped by the given dimension.
-
#scheduled? ⇒ Boolean
Whether the video is scheduled to be published.
-
#scheduled_at ⇒ Time?
Returns the time when a video is scheduled to be published.
-
#self_declared_made_for_kids? ⇒ Boolean
@return [Boolean, nil] In a videos.insert or videos.update request, this property allows the channel owner to designate the video as being child-directed.
-
#shares(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the shares grouped by the given dimension.
-
#stereoscopic? ⇒ Boolean
Whether the video is available in 3D.
-
#subscribers_gained(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the subscribers_gained grouped by the given dimension.
-
#subscribers_lost(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the subscribers_lost grouped by the given dimension.
-
#tags ⇒ Array<String>
The list of tags attached to the video.
-
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of the video’s thumbnail.
-
#too_long? ⇒ Boolean
Whether the video was rejected by YouTube because the video exceeds the maximum duration for YouTube.
-
#too_small? ⇒ Boolean
Whether the video failed to upload to YouTube because the video file is too small for YouTube.
-
#unlike ⇒ Boolean
Resets the rating of the video on behalf of the authenticated account.
-
#update(attributes = {}) ⇒ Boolean
Updates the attributes of a video.
-
#upload_thumbnail(path_or_url) ⇒ Object
Uploads a thumbnail.
-
#uploading? ⇒ Boolean
Whether the video is being uploaded to YouTube.
-
#uses_unsupported_codec? ⇒ Boolean
Whether the video failed to upload to YouTube because of an unsupported codec.
-
#videos_added_to_playlists(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the videos_added_to_playlists grouped by the given dimension.
-
#videos_removed_from_playlists(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the videos_removed_from_playlists grouped by the given dimension.
-
#viewer_percentage(options = {}) ⇒ Hash<Symbol, Float>, ...
Returns the viewer_percentage grouped by the given dimension.
-
#views(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the views grouped by the given dimension.
-
#violates_terms_of_use? ⇒ Boolean
Whether the video was rejected by YouTube because the video violates the Terms of Use.
Methods inherited from Resource
#private?, #public?, #unlisted?
Instance Attribute Details
#actual_end_time ⇒ Time? (readonly)
The time when a live broadcast ended.
374 |
# File 'lib/yt/models/video.rb', line 374 delegate :actual_end_time, to: :live_streaming_detail |
#actual_start_time ⇒ Time? (readonly)
The time when a live broadcast started.
368 |
# File 'lib/yt/models/video.rb', line 368 delegate :actual_start_time, to: :live_streaming_detail |
#ad_formats ⇒ Array<String> (readonly)
Returns the list of ad formats that the video is allowed to show. Possible values are: ‘long’, ‘overlay’, ‘standard_instream’, ‘third_party’, ‘trueview_inslate’, ‘trueview_instream’.
358 |
# File 'lib/yt/models/video.rb', line 358 delegate :ad_formats, to: :advertising_options_set |
#annotations ⇒ Yt::Collections::Annotations (readonly)
Returns the video’s annotations.
406 |
# File 'lib/yt/models/video.rb', line 406 has_many :annotations |
#channel_id ⇒ String (readonly)
Returns the ID of the channel that the video belongs to.
34 |
# File 'lib/yt/models/video.rb', line 34 delegate :channel_id, to: :snippet |
#channel_title ⇒ String (readonly)
Returns the title of the channel that the video belongs to.
38 |
# File 'lib/yt/models/video.rb', line 38 delegate :channel_title, to: :snippet |
#claim ⇒ Object (readonly)
413 414 415 |
# File 'lib/yt/models/video.rb', line 413 def claim @claim end |
#comment_count ⇒ Integer (readonly)
Returns the number of comments for the video.
525 |
# File 'lib/yt/models/video.rb', line 525 delegate :comment_count, to: :statistics_set |
#comments(options = {}) ⇒ Hash<Date, Integer>, ... (readonly)
Returns the comments grouped by the given dimension.
402 |
# File 'lib/yt/models/video.rb', line 402 has_many :comment_threads |
#concurrent_viewers ⇒ Integer? (readonly)
The number of current viewers of a live broadcast.
397 |
# File 'lib/yt/models/video.rb', line 397 delegate :concurrent_viewers, to: :live_streaming_detail |
#container ⇒ String (readonly)
Returns the video container of the uploaded file. (e.g. ‘mov’).
299 |
# File 'lib/yt/models/video.rb', line 299 delegate :container, to: :file_detail |
#description ⇒ String (readonly)
Returns the video’s description.
17 |
# File 'lib/yt/models/video.rb', line 17 delegate :description, to: :snippet |
#dislike_count ⇒ Integer (readonly)
Returns the number of users who disliked the video.
517 |
# File 'lib/yt/models/video.rb', line 517 delegate :dislike_count, to: :statistics_set |
#duration ⇒ String (readonly)
Returns the length of the video as an ISO 8601 time, HH:MM:SS.
247 |
# File 'lib/yt/models/video.rb', line 247 delegate :duration, to: :content_detail |
#embed_html ⇒ String (readonly)
Returns the HTML code of an <iframe> tag that embeds a player that will play the video.
534 |
# File 'lib/yt/models/video.rb', line 534 delegate :embed_html, to: :player |
#favorite_count ⇒ Integer (readonly)
Returns the number of users who marked the video as favorite.
521 |
# File 'lib/yt/models/video.rb', line 521 delegate :favorite_count, to: :statistics_set |
#file_name ⇒ String (readonly)
Returns the name of the uploaded file.
286 |
# File 'lib/yt/models/video.rb', line 286 delegate :file_name, to: :file_detail |
#file_size ⇒ Integer (readonly)
Returns the size of the uploaded file (in bytes).
290 |
# File 'lib/yt/models/video.rb', line 290 delegate :file_size, to: :file_detail |
#file_type ⇒ String (readonly)
Returns the type of file uploaded. May be one of: archive, audio, document, image, other, project, video.
295 |
# File 'lib/yt/models/video.rb', line 295 delegate :file_type, to: :file_detail |
#license ⇒ String (readonly)
Returns the video’s license. Possible values are: ‘creativeCommon’, ‘youtube’.
197 |
# File 'lib/yt/models/video.rb', line 197 delegate :license, to: :status |
#like_count ⇒ Integer (readonly)
Returns the number of users who liked the video.
513 |
# File 'lib/yt/models/video.rb', line 513 delegate :like_count, to: :statistics_set |
#live_broadcast_content ⇒ String (readonly)
Returns the type of live broadcast that the video contains. Possible values are: ‘live’, ‘none’, ‘upcoming’.
48 |
# File 'lib/yt/models/video.rb', line 48 delegate :live_broadcast_content, to: :snippet |
#published_at ⇒ Time (readonly)
Returns the date and time that the video was published.
30 |
# File 'lib/yt/models/video.rb', line 30 delegate :published_at, to: :snippet |
#scheduled_end_time ⇒ Time? (readonly)
The time when a live broadcast is scheduled to end.
388 |
# File 'lib/yt/models/video.rb', line 388 delegate :scheduled_end_time, to: :live_streaming_detail |
#scheduled_start_time ⇒ Time? (readonly)
The time when a live broadcast is scheduled to start.
380 |
# File 'lib/yt/models/video.rb', line 380 delegate :scheduled_start_time, to: :live_streaming_detail |
#title ⇒ String (readonly)
Returns the video’s title.
13 |
# File 'lib/yt/models/video.rb', line 13 delegate :title, to: :snippet |
#view_count ⇒ Integer (readonly)
Returns the number of times the video has been viewed.
509 |
# File 'lib/yt/models/video.rb', line 509 delegate :view_count, to: :statistics_set |
Instance Method Details
#aborted? ⇒ Boolean
Returns whether the video failed to upload to YouTube because the uploading process was aborted.
121 122 123 |
# File 'lib/yt/models/video.rb', line 121 def aborted? status.failure_reason == 'uploadAborted' end |
#ad_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the ad_impressions grouped by the given dimension.
495 |
# File 'lib/yt/models/video.rb', line 495 has_report :ad_impressions, Integer |
#age_restricted? ⇒ Boolean
Returns whether the video is identified by YouTube as age-restricted content.
276 277 278 |
# File 'lib/yt/models/video.rb', line 276 def age_restricted? content_detail. == 'ytAgeRestricted' end |
#annotation_click_through_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_click_through_rate grouped by the given dimension.
468 |
# File 'lib/yt/models/video.rb', line 468 has_report :annotation_click_through_rate, Float |
#annotation_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the annotation_clicks grouped by the given dimension.
465 |
# File 'lib/yt/models/video.rb', line 465 has_report :annotation_clicks, Integer |
#annotation_close_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_close_rate grouped by the given dimension.
471 |
# File 'lib/yt/models/video.rb', line 471 has_report :annotation_close_rate, Float |
#average_view_duration(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the average_view_duration grouped by the given dimension.
459 |
# File 'lib/yt/models/video.rb', line 459 has_report :average_view_duration, Integer |
#average_view_percentage(options = {}) ⇒ Hash<Date, Float>, ...
Returns the average_view_percentage grouped by the given dimension.
462 |
# File 'lib/yt/models/video.rb', line 462 has_report :average_view_percentage, Float |
#belongs_to_closed_account? ⇒ Boolean
Returns whether the video was rejected by YouTube because the account that uploaded the video has been closed.
171 172 173 |
# File 'lib/yt/models/video.rb', line 171 def belongs_to_closed_account? status.rejection_reason == 'uploaderAccountClosed' end |
#belongs_to_suspended_account? ⇒ Boolean
Returns whether the video was rejected by YouTube because the account that uploaded the video has been suspended.
177 178 179 |
# File 'lib/yt/models/video.rb', line 177 def belongs_to_suspended_account? status.rejection_reason == 'uploaderAccountSuspended' end |
#captioned? ⇒ Boolean
Returns whether captions are available for the video.
264 265 266 |
# File 'lib/yt/models/video.rb', line 264 def content_detail. == 'true' end |
#card_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_click_rate grouped by the given dimension.
480 |
# File 'lib/yt/models/video.rb', line 480 has_report :card_click_rate, Float |
#card_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_clicks grouped by the given dimension.
477 |
# File 'lib/yt/models/video.rb', line 477 has_report :card_clicks, Integer |
#card_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_impressions grouped by the given dimension.
474 |
# File 'lib/yt/models/video.rb', line 474 has_report :card_impressions, Integer |
#card_teaser_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_teaser_click_rate grouped by the given dimension.
489 |
# File 'lib/yt/models/video.rb', line 489 has_report :card_teaser_click_rate, Float |
#card_teaser_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_clicks grouped by the given dimension.
486 |
# File 'lib/yt/models/video.rb', line 486 has_report :card_teaser_clicks, Integer |
#card_teaser_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_impressions grouped by the given dimension.
483 |
# File 'lib/yt/models/video.rb', line 483 has_report :card_teaser_impressions, Integer |
#category_id ⇒ String
Returns ID of the YouTube category associated with the video.
56 57 58 |
# File 'lib/yt/models/video.rb', line 56 def category_id ensure_complete_snippet :category_id end |
#category_title ⇒ String
Returns the video category’s title.
345 346 347 |
# File 'lib/yt/models/video.rb', line 345 def category_title video_category.title end |
#channel_url ⇒ <String>
Returns the URL of the channel that the video belongs to.
41 42 43 |
# File 'lib/yt/models/video.rb', line 41 def channel_url "https://www.youtube.com/channel/#{channel_id}" end |
#claimed? ⇒ Boolean
Returns whether the video was rejected by YouTube because the video was claimed by a different account.
127 128 129 |
# File 'lib/yt/models/video.rb', line 127 def claimed? status.rejection_reason == 'claim' end |
#delete(options = {}) ⇒ Boolean
Deletes the video on behalf of the authenticated account.
557 558 559 560 |
# File 'lib/yt/models/video.rb', line 557 def delete( = {}) do_delete {@id = nil} !exists? end |
#deleted? ⇒ Boolean
Returns whether the video was deleted by the user.
63 64 65 |
# File 'lib/yt/models/video.rb', line 63 def deleted? status.upload_status == 'deleted' end |
#dislike ⇒ Boolean
Dislikes the video on behalf of the authenticated account.
326 327 328 329 |
# File 'lib/yt/models/video.rb', line 326 def dislike .set :dislike !liked? end |
#dislikes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the dislikes grouped by the given dimension.
437 |
# File 'lib/yt/models/video.rb', line 437 has_report :dislikes, Integer |
#duplicate? ⇒ Boolean
Returns whether the video was rejected by YouTube because the video is a duplicate of another video.
139 140 141 |
# File 'lib/yt/models/video.rb', line 139 def duplicate? status.rejection_reason == 'duplicate' end |
#embeddable? ⇒ Boolean
Returns whether the video can be embedded on other websites.
222 223 224 |
# File 'lib/yt/models/video.rb', line 222 def status. end |
#empty? ⇒ Boolean
Returns whether the video failed to upload to YouTube because the video file is empty.
102 103 104 |
# File 'lib/yt/models/video.rb', line 102 def empty? status.failure_reason == 'emptyFile' end |
#estimated_minutes_watched(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the estimated_minutes_watched grouped by the given dimension.
425 |
# File 'lib/yt/models/video.rb', line 425 has_report :estimated_minutes_watched, Integer |
#estimated_revenue(options = {}) ⇒ Hash<Date, Float>, ...
Returns the estimated_revenue grouped by the given dimension.
492 |
# File 'lib/yt/models/video.rb', line 492 has_report :estimated_revenue, Float |
#failed? ⇒ Boolean
Returns whether the video failed to upload.
68 69 70 |
# File 'lib/yt/models/video.rb', line 68 def failed? status.upload_status == 'failed' end |
#has_failed_conversion? ⇒ Boolean
Returns whether the video failed to upload to YouTube because YouTube was unable to convert the video.
96 97 98 |
# File 'lib/yt/models/video.rb', line 96 def has_failed_conversion? status.failure_reason == 'conversion' end |
#has_public_stats_viewable? ⇒ Boolean
Returns whether the video statistics are publicly viewable.
217 218 219 |
# File 'lib/yt/models/video.rb', line 217 def has_public_stats_viewable? status.public_stats_viewable end |
#hd? ⇒ Boolean
Returns whether the video is available in high definition.
259 260 261 |
# File 'lib/yt/models/video.rb', line 259 def hd? content_detail.definition == 'hd' end |
#inappropriate? ⇒ Boolean
Returns whether the video was rejected by YouTube because the video contains inappropriate content.
145 146 147 |
# File 'lib/yt/models/video.rb', line 145 def inappropriate? status.rejection_reason == 'inappropriate' end |
#infringes_copyright? ⇒ Boolean
Returns whether the video was rejected by YouTube because the video commits a copyright infringement.
133 134 135 |
# File 'lib/yt/models/video.rb', line 133 def infringes_copyright? status.rejection_reason == 'copyright' end |
#infringes_trademark? ⇒ Boolean
Returns whether the video was rejected by YouTube because the video infringes a trademark.
165 166 167 |
# File 'lib/yt/models/video.rb', line 165 def infringes_trademark? status.rejection_reason == 'trademark' end |
#invalid? ⇒ Boolean
Returns whether the video failed to upload to YouTube because the video uses an unsupported file format.
109 110 111 |
# File 'lib/yt/models/video.rb', line 109 def invalid? status.failure_reason == 'invalidFile' end |
#licensed? ⇒ Boolean
Returns whether the video represents licensed content, which means that the content has been claimed by a YouTube content partner.
270 271 272 |
# File 'lib/yt/models/video.rb', line 270 def licensed? content_detail.licensed_content || false end |
#licensed_as_creative_commons? ⇒ Boolean
Returns whether the video uses a Creative Commons license.
207 208 209 |
# File 'lib/yt/models/video.rb', line 207 def licensed_as_creative_commons? license == 'creativeCommon' end |
#licensed_as_standard_youtube? ⇒ Boolean
Returns whether the video uses the Standard YouTube license.
201 202 203 |
# File 'lib/yt/models/video.rb', line 201 def licensed_as_standard_youtube? license == 'youtube' end |
#like ⇒ Boolean
Likes the video on behalf of the authenticated account.
317 318 319 320 |
# File 'lib/yt/models/video.rb', line 317 def like .set :like liked? end |
#liked? ⇒ Boolean
Returns whether the authenticated account likes the video.
309 310 311 |
# File 'lib/yt/models/video.rb', line 309 def liked? . == :like end |
#likes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the likes grouped by the given dimension.
434 |
# File 'lib/yt/models/video.rb', line 434 has_report :likes, Integer |
#made_for_kids? ⇒ Boolean
@return [Boolean, nil] This value indicates whether the video is
designated as child-directed, and it contains the current "made for
kids" status of the video.
229 230 231 |
# File 'lib/yt/models/video.rb', line 229 def made_for_kids? status.made_for_kids end |
#monetized_playbacks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the monetized_playbacks grouped by the given dimension.
498 |
# File 'lib/yt/models/video.rb', line 498 has_report :monetized_playbacks, Integer |
#playback_based_cpm(options = {}) ⇒ Hash<Date, Float>, ...
Returns the playback_based_cpm grouped by the given dimension.
501 |
# File 'lib/yt/models/video.rb', line 501 has_report :playback_based_cpm, Float |
#processed? ⇒ Boolean
Returns whether the video has been fully processed by YouTube.
73 74 75 |
# File 'lib/yt/models/video.rb', line 73 def processed? status.upload_status == 'processed' end |
#rejected? ⇒ Boolean
Returns whether the video was rejected by YouTube.
78 79 80 |
# File 'lib/yt/models/video.rb', line 78 def rejected? status.upload_status == 'rejected' end |
#reports(options = {}) ⇒ Hash<Symbol, Hash>
Returns the reports for the given metrics grouped by the given dimension.
|
# File 'lib/yt/models/video.rb', line 419
|
#scheduled? ⇒ Boolean
Returns whether the video is scheduled to be published.
190 191 192 |
# File 'lib/yt/models/video.rb', line 190 def scheduled? private? && status.publish_at end |
#scheduled_at ⇒ Time?
Returns the time when a video is scheduled to be published.
185 186 187 |
# File 'lib/yt/models/video.rb', line 185 def scheduled_at status.publish_at if scheduled? end |
#self_declared_made_for_kids? ⇒ Boolean
@return [Boolean, nil] In a videos.insert or videos.update request,
this property allows the channel owner to designate the video as
being child-directed. In a videos.list request, the property value
is only returned if the channel owner authorized the API request.
237 238 239 |
# File 'lib/yt/models/video.rb', line 237 def self_declared_made_for_kids? status.self_declared_made_for_kids end |
#shares(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the shares grouped by the given dimension.
440 |
# File 'lib/yt/models/video.rb', line 440 has_report :shares, Integer |
#stereoscopic? ⇒ Boolean
Returns whether the video is available in 3D.
254 255 256 |
# File 'lib/yt/models/video.rb', line 254 def stereoscopic? content_detail.dimension == '3d' end |
#subscribers_gained(options = {}) ⇒ Hash<Date, Integer>, ...
This is not the total number of subscribers gained by the video’s channel, but the subscribers gained from the video’s page.
Returns the subscribers_gained grouped by the given dimension.
445 |
# File 'lib/yt/models/video.rb', line 445 has_report :subscribers_gained, Integer |
#subscribers_lost(options = {}) ⇒ Hash<Date, Integer>, ...
This is not the total number of subscribers lost by the video’s channel, but the subscribers lost from the video’s page.
Returns the subscribers_lost grouped by the given dimension.
450 |
# File 'lib/yt/models/video.rb', line 450 has_report :subscribers_lost, Integer |
#tags ⇒ Array<String>
Returns the list of tags attached to the video.
51 52 53 |
# File 'lib/yt/models/video.rb', line 51 def ensure_complete_snippet :tags end |
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of the video’s thumbnail.
26 |
# File 'lib/yt/models/video.rb', line 26 delegate :thumbnail_url, to: :snippet |
#too_long? ⇒ Boolean
Returns whether the video was rejected by YouTube because the video exceeds the maximum duration for YouTube.
152 153 154 |
# File 'lib/yt/models/video.rb', line 152 def too_long? status.rejection_reason == 'length' end |
#too_small? ⇒ Boolean
Returns whether the video failed to upload to YouTube because the video file is too small for YouTube.
115 116 117 |
# File 'lib/yt/models/video.rb', line 115 def too_small? status.failure_reason == 'tooSmall' end |
#unlike ⇒ Boolean
Resets the rating of the video on behalf of the authenticated account.
335 336 337 338 |
# File 'lib/yt/models/video.rb', line 335 def unlike .set :none !liked? end |
#update(attributes = {}) ⇒ Boolean
Updates the attributes of a video.
597 598 599 |
# File 'lib/yt/models/video.rb', line 597 def update(attributes = {}) super end |
#upload_thumbnail(path_or_url) ⇒ Object
Uploads a thumbnail
544 545 546 547 548 549 550 551 |
# File 'lib/yt/models/video.rb', line 544 def upload_thumbnail(path_or_url) file = open(path_or_url, 'rb') rescue StringIO.new session = resumable_sessions.insert file.size session.update(body: file) do |data| snippet.instance_variable_set :@thumbnails, data['items'].first end end |
#uploading? ⇒ Boolean
Returns whether the video is being uploaded to YouTube.
83 84 85 |
# File 'lib/yt/models/video.rb', line 83 def uploading? status.upload_status == 'uploaded' end |
#uses_unsupported_codec? ⇒ Boolean
Returns whether the video failed to upload to YouTube because of an unsupported codec.
90 91 92 |
# File 'lib/yt/models/video.rb', line 90 def uses_unsupported_codec? status.failure_reason == 'codec' end |
#videos_added_to_playlists(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the videos_added_to_playlists grouped by the given dimension.
453 |
# File 'lib/yt/models/video.rb', line 453 has_report :videos_added_to_playlists, Integer |
#videos_removed_from_playlists(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the videos_removed_from_playlists grouped by the given dimension.
456 |
# File 'lib/yt/models/video.rb', line 456 has_report :videos_removed_from_playlists, Integer |
#viewer_percentage(options = {}) ⇒ Hash<Symbol, Float>, ...
Returns the viewer_percentage grouped by the given dimension.
428 |
# File 'lib/yt/models/video.rb', line 428 has_report :viewer_percentage, Float |
#views(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the views grouped by the given dimension.
422 |
# File 'lib/yt/models/video.rb', line 422 has_report :views, Integer |
#violates_terms_of_use? ⇒ Boolean
Returns whether the video was rejected by YouTube because the video violates the Terms of Use.
158 159 160 |
# File 'lib/yt/models/video.rb', line 158 def violates_terms_of_use? status.rejection_reason == 'termsOfUse' end |