Class: YTAnalytics::Client
- Inherits:
-
Object
- Object
- YTAnalytics::Client
- Includes:
- Logging
- Defined in:
- lib/yt_analytics/client.rb
Direct Known Subclasses
Instance Method Summary collapse
- #analytics(opts = {}) ⇒ Object
- #current_user ⇒ Object
- #day_totals(start_date = 2.day.ago, end_date = 2.day.ago) ⇒ Object
- #enable_http_debugging ⇒ Object
-
#initialize(*params) ⇒ Client
constructor
Previously this was a logger instance but we now do it globally.
- #month_totals(start_date = 2.day.ago, end_date = 2.day.ago) ⇒ Object
-
#my_video(video_id) ⇒ Object
Gets the authenticated users video with the given ID.
-
#my_videos(opts = {}) ⇒ Object
Gets all videos.
- #seven_day_totals(start_date = 2.day.ago, end_date = 2.day.ago) ⇒ Object
- #thirty_day_totals(start_date = 2.day.ago, end_date = 2.day.ago) ⇒ Object
-
#watch_history ⇒ Object
Gets the user’s watch history.
Methods included from Logging
Constructor Details
#initialize(*params) ⇒ Client
Previously this was a logger instance but we now do it globally
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/yt_analytics/client.rb', line 6 def initialize *params if params.first.is_a?(Hash) = params.first @user = [:username] @pass = [:password] @dev_key = [:dev_key] @client_id = [:client_id] || "yt_analytics" @legacy_debug_flag = [:debug] elsif params.first puts "* warning: the method YTAnalytics::Client.new(user, passwd, dev_key) is deprecated, use YTAnalytics::Client.new(:username => 'user', :password => 'passwd', :dev_key => 'dev_key')" @user = params.shift @pass = params.shift @dev_key = params.shift @client_id = params.shift || "youtube_it" @legacy_debug_flag = params.shift end end |
Instance Method Details
#analytics(opts = {}) ⇒ Object
47 48 49 |
# File 'lib/yt_analytics/client.rb', line 47 def analytics(opts = {}) client.get_analytics(opts) end |
#current_user ⇒ Object
28 29 30 |
# File 'lib/yt_analytics/client.rb', line 28 def current_user client.get_current_user end |
#day_totals(start_date = 2.day.ago, end_date = 2.day.ago) ⇒ Object
59 60 61 |
# File 'lib/yt_analytics/client.rb', line 59 def day_totals(start_date = 2.day.ago, end_date = 2.day.ago) client.temporal_totals('day',start_date, end_date, self.user_id) end |
#enable_http_debugging ⇒ Object
24 25 26 |
# File 'lib/yt_analytics/client.rb', line 24 def enable_http_debugging client.enable_http_debugging end |
#month_totals(start_date = 2.day.ago, end_date = 2.day.ago) ⇒ Object
63 64 65 |
# File 'lib/yt_analytics/client.rb', line 63 def month_totals(start_date = 2.day.ago, end_date = 2.day.ago) client.temporal_totals('month',start_date, end_date, self.user_id) end |
#my_video(video_id) ⇒ Object
Gets the authenticated users video with the given ID. It may be private.
33 34 35 |
# File 'lib/yt_analytics/client.rb', line 33 def my_video(video_id) client.get_my_video(video_id) end |
#my_videos(opts = {}) ⇒ Object
Gets all videos
38 39 40 |
# File 'lib/yt_analytics/client.rb', line 38 def my_videos(opts = {}) client.get_my_videos(opts) end |
#seven_day_totals(start_date = 2.day.ago, end_date = 2.day.ago) ⇒ Object
51 52 53 |
# File 'lib/yt_analytics/client.rb', line 51 def seven_day_totals(start_date = 2.day.ago, end_date = 2.day.ago) client.temporal_totals('7DayTotals',start_date, end_date, self.user_id) end |
#thirty_day_totals(start_date = 2.day.ago, end_date = 2.day.ago) ⇒ Object
55 56 57 |
# File 'lib/yt_analytics/client.rb', line 55 def thirty_day_totals(start_date = 2.day.ago, end_date = 2.day.ago) client.temporal_totals('30DayTotals',start_date, end_date, self.user_id) end |
#watch_history ⇒ Object
Gets the user’s watch history
43 44 45 |
# File 'lib/yt_analytics/client.rb', line 43 def watch_history client.get_watch_history end |