Class: Yt::Models::Video
- Defined in:
- lib/yt/models/video.rb
Overview
Provides methods to interact with YouTube videos.
Instance Attribute Summary collapse
-
#annotations ⇒ Yt::Collections::Annotations
readonly
The video’s annotations.
-
#content_detail ⇒ Yt::Models::ContentDetail
readonly
The video’s content details.
-
#rating ⇒ Yt::Models::Rating
readonly
The video’s rating.
-
#statistics_set ⇒ Yt::Models::StatisticsSet
readonly
The statistics for the video.
Attributes inherited from Resource
Instance Method Summary collapse
-
#comments(options = {}) ⇒ Hash<Date, Float>
The comments for a range of a days.
-
#comments_on(date) ⇒ Float
The comments for a single day.
-
#dislike ⇒ Boolean
Dislikes the video on behalf of the authenticated account.
-
#dislikes(options = {}) ⇒ Hash<Date, Float>
The dislikes for a range of a days.
-
#dislikes_on(date) ⇒ Float
The dislikes for a single day.
-
#earnings(options = {}) ⇒ Hash<Date, Float>
The earnings for a range of a days.
-
#earnings_on(date) ⇒ Float
The earnings for a single day.
-
#impressions(options = {}) ⇒ Hash<Date, Float>
The impressions for a range of a days.
-
#impressions_on(date) ⇒ Float
The impressions for a single day.
-
#like ⇒ Boolean
Likes the video on behalf of the authenticated account.
-
#liked? ⇒ Boolean
Returns whether the authenticated account likes the video.
-
#likes(options = {}) ⇒ Hash<Date, Float>
The likes for a range of a days.
-
#likes_on(date) ⇒ Float
The likes for a single day.
-
#shares(options = {}) ⇒ Hash<Date, Float>
The shares for a range of a days.
-
#shares_on(date) ⇒ Float
The shares for a single day.
-
#unlike ⇒ Boolean
Resets the rating of the video on behalf of the authenticated account.
- #update(options = {}) ⇒ Object
-
#viewer_percentage(filters = {}) ⇒ Float
The percentage of viewer matching the filters.
-
#viewer_percentages ⇒ Hash<Symbol,Hash<String,Float>>
The viewer percentages.
-
#views(options = {}) ⇒ Hash<Date, Float>
The views for a range of a days.
-
#views_on(date) ⇒ Float
The views for a single day.
Methods inherited from Resource
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
This class inherits a constructor from Yt::Models::Resource
Instance Attribute Details
#annotations ⇒ Yt::Collections::Annotations (readonly)
Returns the video’s annotations.
32 |
# File 'lib/yt/models/video.rb', line 32 has_many :annotations |
#content_detail ⇒ Yt::Models::ContentDetail (readonly)
Returns the video’s content details.
22 |
# File 'lib/yt/models/video.rb', line 22 has_one :content_detail |
#rating ⇒ Yt::Models::Rating (readonly)
Returns the video’s rating.
28 |
# File 'lib/yt/models/video.rb', line 28 has_one :rating |
#statistics_set ⇒ Yt::Models::StatisticsSet (readonly)
Returns the statistics for the video.
60 |
# File 'lib/yt/models/video.rb', line 60 has_one :statistics_set |
Instance Method Details
#comments(options = {}) ⇒ Hash<Date, Float>
Returns the comments for a range of a days.
41 |
# File 'lib/yt/models/video.rb', line 41 has_report :comments |
#comments_on(date) ⇒ Float
Returns the comments for a single day.
41 |
# File 'lib/yt/models/video.rb', line 41 has_report :comments |
#dislike ⇒ Boolean
113 114 115 116 |
# File 'lib/yt/models/video.rb', line 113 def dislike .update :dislike !liked? end |
#dislikes(options = {}) ⇒ Hash<Date, Float>
Returns the dislikes for a range of a days.
47 |
# File 'lib/yt/models/video.rb', line 47 has_report :dislikes |
#dislikes_on(date) ⇒ Float
Returns the dislikes for a single day.
47 |
# File 'lib/yt/models/video.rb', line 47 has_report :dislikes |
#earnings(options = {}) ⇒ Hash<Date, Float>
Returns the earnings for a range of a days.
35 |
# File 'lib/yt/models/video.rb', line 35 has_report :earnings |
#earnings_on(date) ⇒ Float
Returns the earnings for a single day.
35 |
# File 'lib/yt/models/video.rb', line 35 has_report :earnings |
#impressions(options = {}) ⇒ Hash<Date, Float>
Returns the impressions for a range of a days.
53 |
# File 'lib/yt/models/video.rb', line 53 has_report :impressions |
#impressions_on(date) ⇒ Float
Returns the impressions for a single day.
53 |
# File 'lib/yt/models/video.rb', line 53 has_report :impressions |
#like ⇒ Boolean
101 102 103 104 |
# File 'lib/yt/models/video.rb', line 101 def like .update :like liked? end |
#liked? ⇒ Boolean
90 91 92 |
# File 'lib/yt/models/video.rb', line 90 def liked? . == :like end |
#likes(options = {}) ⇒ Hash<Date, Float>
Returns the likes for a range of a days.
44 |
# File 'lib/yt/models/video.rb', line 44 has_report :likes |
#likes_on(date) ⇒ Float
Returns the likes for a single day.
44 |
# File 'lib/yt/models/video.rb', line 44 has_report :likes |
#shares(options = {}) ⇒ Hash<Date, Float>
Returns the shares for a range of a days.
50 |
# File 'lib/yt/models/video.rb', line 50 has_report :shares |
#shares_on(date) ⇒ Float
Returns the shares for a single day.
50 |
# File 'lib/yt/models/video.rb', line 50 has_report :shares |
#unlike ⇒ Boolean
125 126 127 128 |
# File 'lib/yt/models/video.rb', line 125 def unlike .update :none !liked? end |
#update(options = {}) ⇒ Object
Update the status, not just the snippet. This requires some caution, as the whole status object needs to be updated, not just privacyStatus, but also embeddable, license, publicStatsViewable, and publishAt
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/yt/models/video.rb', line 68 def update( = {}) [:title] ||= title [:description] ||= description [:tags] ||= [:categoryId] ||= category_id snippet = .slice :title, :description, :tags, :categoryId body = {id: @id, snippet: snippet} do_update(params: {part: 'snippet'}, body: body) do |data| @id = data['id'] @snippet = Snippet.new data: data['snippet'] if data['snippet'] true end end |
#viewer_percentage(filters = {}) ⇒ Float
Returns the percentage of viewer matching the filters.
56 |
# File 'lib/yt/models/video.rb', line 56 has_viewer_percentages |
#viewer_percentages ⇒ Hash<Symbol,Hash<String,Float>>
Returns the viewer percentages. The first-level hash identifies the genres (:female, :male). The second-level hash identifies the age ranges (‘18-24’, ‘25-34’, ‘35-44’, ‘45-54’, ‘55-64’, ‘65-’).
56 |
# File 'lib/yt/models/video.rb', line 56 has_viewer_percentages |
#views(options = {}) ⇒ Hash<Date, Float>
Returns the views for a range of a days.
38 |
# File 'lib/yt/models/video.rb', line 38 has_report :views |
#views_on(date) ⇒ Float
Returns the views for a single day.
38 |
# File 'lib/yt/models/video.rb', line 38 has_report :views |