yt 0.33.4 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/MIT-LICENSE +2 -2
  4. data/README.md +7 -7
  5. data/lib/yt/actions/get.rb +3 -3
  6. data/lib/yt/actions/insert.rb +1 -1
  7. data/lib/yt/actions/list.rb +2 -3
  8. data/lib/yt/associations/has_authentication.rb +5 -3
  9. data/lib/yt/collections/authentications.rb +2 -2
  10. data/lib/yt/collections/branding_settings.rb +30 -0
  11. data/lib/yt/collections/captions.rb +30 -0
  12. data/lib/yt/collections/channel_sections.rb +45 -0
  13. data/lib/yt/collections/device_flows.rb +3 -2
  14. data/lib/yt/collections/live_cuepoints.rb +37 -0
  15. data/lib/yt/collections/reports.rb +14 -6
  16. data/lib/yt/collections/revocations.rb +4 -4
  17. data/lib/yt/collections/user_infos.rb +2 -2
  18. data/lib/yt/models/account.rb +5 -1
  19. data/lib/yt/models/branding_setting.rb +29 -0
  20. data/lib/yt/models/caption.rb +52 -0
  21. data/lib/yt/models/channel.rb +29 -0
  22. data/lib/yt/models/channel_section.rb +25 -0
  23. data/lib/yt/models/content_owner.rb +5 -1
  24. data/lib/yt/models/group_info.rb +1 -1
  25. data/lib/yt/models/live_cuepoint.rb +23 -0
  26. data/lib/yt/models/playlist.rb +4 -5
  27. data/lib/yt/models/reference.rb +1 -1
  28. data/lib/yt/models/resource.rb +45 -22
  29. data/lib/yt/models/resumable_session.rb +1 -2
  30. data/lib/yt/models/snippet.rb +5 -0
  31. data/lib/yt/models/statistics_set.rb +5 -0
  32. data/lib/yt/models/user_info.rb +1 -0
  33. data/lib/yt/models/video.rb +9 -1
  34. data/lib/yt/models/video_group.rb +3 -0
  35. data/lib/yt/request.rb +5 -0
  36. data/lib/yt/version.rb +1 -1
  37. data/lib/yt.rb +1 -0
  38. metadata +19 -92
  39. data/.gitignore +0 -27
  40. data/.rspec +0 -3
  41. data/.travis.yml +0 -7
  42. data/Gemfile +0 -4
  43. data/Rakefile +0 -11
  44. data/bin/yt +0 -23
  45. data/gemfiles/Gemfile.activesupport-3.x +0 -4
  46. data/gemfiles/Gemfile.activesupport-4.x +0 -4
  47. data/lib/yt/models/iterator.rb +0 -16
  48. data/yt.gemspec +0 -36
@@ -0,0 +1,23 @@
1
+ require 'yt/models/base'
2
+
3
+ module Yt
4
+ module Models
5
+ # Provides methods to interact with YouTube Content ID live cuepoints.
6
+ # @see https://developers.google.com/youtube/v3/live/docs/liveCuepoints
7
+ class LiveCuepoint < Base
8
+ def initialize(options = {})
9
+ @data = options[:data]
10
+ @id = options[:id]
11
+ @auth = options[:auth]
12
+ end
13
+
14
+ # @return [String] the ID that YouTube assigns and uses to uniquely
15
+ # identify the live_cuepoint.
16
+ has_attribute :id
17
+
18
+ # @return [String] the ID that uniquely identifies the broadcast that the
19
+ # live_cuepoint is associated with.
20
+ has_attribute :broadcast_id
21
+ end
22
+ end
23
+ end
@@ -37,10 +37,6 @@ module Yt
37
37
  # @return [String] the title of the channel that the playlist belongs to.
38
38
  delegate :channel_title, to: :snippet
39
39
 
40
- # @!attribute [r] tags
41
- # @return [Array<String>] the list of tags attached to the playlist.
42
- delegate :tags, to: :snippet
43
-
44
40
  ### STATISTICS ###
45
41
 
46
42
  has_one :content_detail
@@ -164,6 +160,9 @@ module Yt
164
160
  # @macro report_by_playlist_dimensions
165
161
  has_report :views, Integer
166
162
 
163
+ # @macro report_by_playlist_dimensions
164
+ has_report :engaged_views, Integer
165
+
167
166
  # @macro report_by_playlist_dimensions
168
167
  has_report :estimated_minutes_watched, Integer
169
168
 
@@ -206,7 +205,7 @@ module Yt
206
205
  else
207
206
  params[:ids] = "channel==#{channel_id}"
208
207
  end
209
- params[:filters] = "playlist==#{id};isCurated==1"
208
+ params[:filters] = "playlist==#{id}"
210
209
  end
211
210
  end
212
211
 
@@ -169,4 +169,4 @@ module Yt
169
169
  end
170
170
  end
171
171
  end
172
- end
172
+ end
@@ -12,13 +12,7 @@ module Yt
12
12
 
13
13
  # @!attribute [r] id
14
14
  # @return [String] the ID that YouTube uses to identify each resource.
15
- def id
16
- if @id.nil? && @match && @match[:kind] == :channel
17
- @id ||= fetch_channel_id
18
- else
19
- @id
20
- end
21
- end
15
+ attr_reader :id
22
16
 
23
17
  ### STATUS ###
24
18
 
@@ -51,7 +45,11 @@ module Yt
51
45
  if options[:url]
52
46
  @url = options[:url]
53
47
  @match = find_pattern_match
54
- @id = @match['id']
48
+ if kind == "channel" && @match.key?('format')
49
+ @id ||= fetch_channel_id
50
+ else
51
+ @id = @match['id']
52
+ end
55
53
  else
56
54
  @id = options[:id]
57
55
  end
@@ -98,7 +96,8 @@ module Yt
98
96
  # @return [Array<Regexp>] patterns matching URLs of YouTube channels.
99
97
  CHANNEL_PATTERNS = [
100
98
  %r{^(?:https?://)?(?:www\.)?youtube\.com/channel/(?<id>UC[a-zA-Z0-9_-]{22})},
101
- %r{^(?:https?://)?(?:www\.)?youtube\.com/(?<format>c/|user/)?(?<name>[a-zA-Z0-9_-]+)}
99
+ %r{^(?:https?://)?(?:www\.)?youtube\.com/(?<format>c/|user/)?(?<name>[a-zA-Z0-9_-]+)},
100
+ %r{^(?:https?://)?(?:www\.)?youtube\.com/(?<format>@)(?<name>[a-zA-Z0-9_-]+)}
102
101
  ]
103
102
 
104
103
  private
@@ -106,8 +105,7 @@ module Yt
106
105
  def find_pattern_match
107
106
  patterns.find do |kind, regex|
108
107
  if data = @url.match(regex)
109
- # Note: With Ruby 2.4, the following is data.named_captures
110
- break data.names.zip(data.captures).to_h.merge kind: kind
108
+ break data.named_captures.merge kind: kind
111
109
  end
112
110
  end || {kind: :unknown}
113
111
  end
@@ -123,19 +121,44 @@ module Yt
123
121
  end
124
122
 
125
123
  def fetch_channel_id
126
- response = Net::HTTP.start 'www.youtube.com', 443, use_ssl: true do |http|
127
- http.request Net::HTTP::Get.new("/#{@match['format']}#{@match['name']}")
128
- end
129
- if response.is_a?(Net::HTTPRedirection)
124
+ api_key = Yt.configuration.api_key if Yt.configuration.api_key
125
+ case @match['format']
126
+ when "@"
127
+ handle = "@#{@match['name']}"
128
+ response = Net::HTTP.start 'youtube.googleapis.com', 443, use_ssl: true do |http|
129
+ http.request Net::HTTP::Get.new("/youtube/v3/channels?part=snippet&forHandle=#{handle}&key=#{api_key}")
130
+ end
131
+ if response.is_a?(Net::HTTPOK) && item = JSON(response.body)['items']&.first
132
+ item['id']
133
+ else
134
+ raise Yt::Errors::NoItems
135
+ end
136
+ when "user/"
137
+ username = @match['name']
138
+ response = Net::HTTP.start 'youtube.googleapis.com', 443, use_ssl: true do |http|
139
+ http.request Net::HTTP::Get.new("/youtube/v3/channels?part=snippet&forUsername=#{username}&key=#{api_key}")
140
+ end
141
+ if response.is_a?(Net::HTTPOK) && item = JSON(response.body)['items']&.first
142
+ item['id']
143
+ else
144
+ raise Yt::Errors::NoItems
145
+ end
146
+ else # "c/", nil
130
147
  response = Net::HTTP.start 'www.youtube.com', 443, use_ssl: true do |http|
131
- http.request Net::HTTP::Get.new(response['location'])
148
+ http.request Net::HTTP::Get.new("/#{@match['format']}#{@match['name']}")
149
+ end
150
+ if response.is_a?(Net::HTTPRedirection)
151
+ response = Net::HTTP.start 'www.youtube.com', 443, use_ssl: true do |http|
152
+ http.request Net::HTTP::Get.new(response['location'])
153
+ end
154
+ end
155
+ # puts response.body
156
+ regex = %r{(?<id>UC[a-zA-Z0-9_-]{22})}
157
+ if data = response.body.match(regex)
158
+ data[:id]
159
+ else
160
+ raise Yt::Errors::NoItems
132
161
  end
133
- end
134
- regex = %r{<meta itemprop="channelId" content="(?<id>UC[a-zA-Z0-9_-]{22})">}
135
- if data = response.body.match(regex)
136
- data[:id]
137
- else
138
- raise Yt::Errors::NoItems
139
162
  end
140
163
  end
141
164
 
@@ -1,4 +1,3 @@
1
- require 'cgi'
2
1
  require 'yt/models/base'
3
2
 
4
3
  module Yt
@@ -30,7 +29,7 @@ module Yt
30
29
  private
31
30
 
32
31
  def session_params
33
- CGI::parse(@uri.query).tap{|hash| hash.each{|k,v| hash[k] = v.first}}
32
+ URI.decode_www_form(@uri.query || "").to_h
34
33
  end
35
34
 
36
35
  # @note: YouTube documentation states that a valid upload returns an HTTP
@@ -38,6 +38,11 @@ module Yt
38
38
  has_attribute :like_count, type: Integer
39
39
  has_attribute :updated_at, type: Time
40
40
 
41
+ has_attribute :last_updated, type: Time
42
+ has_attribute :language
43
+ has_attribute :name
44
+ has_attribute :status
45
+
41
46
  def thumbnail_url(size = :default)
42
47
  thumbnails.fetch(size.to_s, {})['url']
43
48
  end
@@ -17,7 +17,12 @@ module Yt
17
17
  has_attribute :view_count, type: Integer
18
18
  has_attribute :comment_count, type: Integer
19
19
  has_attribute :like_count, type: Integer
20
+
21
+ # statistics.dislikeCount property included in an API response
22
+ # only if the API request was authenticated by the video owner
23
+ # as of December 13, 2021
20
24
  has_attribute :dislike_count, type: Integer
25
+
21
26
  has_attribute :favorite_count, type: Integer
22
27
  has_attribute :video_count, type: Integer
23
28
  has_attribute :subscriber_count, type: Integer
@@ -11,6 +11,7 @@ module Yt
11
11
  end
12
12
 
13
13
  has_attribute :id, default: ''
14
+ has_attribute :sub, default: ''
14
15
  has_attribute :email, default: ''
15
16
  has_attribute :verified_email, default: false, camelize: false
16
17
  has_attribute :name, default: ''
@@ -1,3 +1,4 @@
1
+ require 'open-uri'
1
2
  require 'yt/models/resource'
2
3
 
3
4
  module Yt
@@ -421,6 +422,9 @@ module Yt
421
422
  # @macro report_by_video_dimensions
422
423
  has_report :views, Integer
423
424
 
425
+ # @macro report_by_video_dimensions
426
+ has_report :engaged_views, Integer
427
+
424
428
  # @macro report_by_video_dimensions
425
429
  has_report :estimated_minutes_watched, Integer
426
430
 
@@ -533,6 +537,10 @@ module Yt
533
537
  # player that will play the video.
534
538
  delegate :embed_html, to: :player
535
539
 
540
+ ### CAPTION ###
541
+
542
+ has_many :captions
543
+
536
544
  ### ACTIONS (UPLOAD, UPDATE, DELETE) ###
537
545
 
538
546
  # Uploads a thumbnail
@@ -542,7 +550,7 @@ module Yt
542
550
  # @raise [Yt::Errors::RequestError] if path_or_url is not a valid path
543
551
  # or URL.
544
552
  def upload_thumbnail(path_or_url)
545
- file = open(path_or_url, 'rb') rescue StringIO.new
553
+ file = URI.open(path_or_url)
546
554
  session = resumable_sessions.insert file.size
547
555
 
548
556
  session.update(body: file) do |data|
@@ -37,6 +37,9 @@ module Yt
37
37
  # @macro report_by_video_dimensions
38
38
  has_report :views, Integer
39
39
 
40
+ # @macro report_by_video_dimensions
41
+ has_report :engaged_views, Integer
42
+
40
43
  # @macro report_by_video_dimensions
41
44
  has_report :estimated_minutes_watched, Integer
42
45
 
data/lib/yt/request.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'net/http' # for Net::HTTP.start
2
2
  require 'uri' # for URI.json
3
3
  require 'json' # for JSON.parse
4
+ require "open-uri" # for URI.open
4
5
  require 'active_support' # does not load anything by default, but is required
5
6
  require 'active_support/core_ext' # for Hash.from_xml, Hash.to_param
6
7
 
@@ -84,6 +85,10 @@ module Yt
84
85
  end
85
86
  end
86
87
 
88
+ def open_uri
89
+ URI.open(uri.to_s, 'Authorization' => "Bearer #{@auth.access_token}")
90
+ end
91
+
87
92
  # Returns the +cURL+ version of the request, useful to re-run the request
88
93
  # in a shell terminal.
89
94
  # @return [String] the +cURL+ version of the request.
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.33.4'
2
+ VERSION = '0.34.1'
3
3
  end
data/lib/yt.rb CHANGED
@@ -14,6 +14,7 @@ require 'yt/models/video_group'
14
14
  require 'yt/models/comment_thread'
15
15
  require 'yt/models/ownership'
16
16
  require 'yt/models/advertising_options_set'
17
+ require 'yt/models/caption'
17
18
 
18
19
  # An object-oriented Ruby client for YouTube.
19
20
  # Helps creating applications that need to interact with YouTube objects.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.33.4
4
+ version: 0.34.1
5
5
  platform: ruby
6
6
  authors:
7
- - Claudio Baccigalupo
8
- autorequire:
7
+ - Nullscreen
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-15 00:00:00.000000000 Z
11
+ date: 2026-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rspec
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,62 +38,6 @@ dependencies:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: yard
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: coveralls
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: pry
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
41
  - !ruby/object:Gem::Dependency
112
42
  name: vcr
113
43
  requirement: !ruby/object:Gem::Requirement
@@ -138,25 +68,16 @@ dependencies:
138
68
  version: '0'
139
69
  description: Youtube V3 API client.
140
70
  email:
141
- - claudio@fullscreen.net
142
- executables:
143
- - yt
71
+ - nullscreen.code@gmail.com
72
+ executables: []
144
73
  extensions: []
145
74
  extra_rdoc_files: []
146
75
  files:
147
- - ".gitignore"
148
- - ".rspec"
149
- - ".travis.yml"
150
76
  - ".yardopts"
151
77
  - CHANGELOG.md
152
- - Gemfile
153
78
  - MIT-LICENSE
154
79
  - README.md
155
- - Rakefile
156
80
  - YOUTUBE_IT.md
157
- - bin/yt
158
- - gemfiles/Gemfile.activesupport-3.x
159
- - gemfiles/Gemfile.activesupport-4.x
160
81
  - lib/yt.rb
161
82
  - lib/yt/actions/base.rb
162
83
  - lib/yt/actions/delete.rb
@@ -177,8 +98,11 @@ files:
177
98
  - lib/yt/collections/assets.rb
178
99
  - lib/yt/collections/authentications.rb
179
100
  - lib/yt/collections/base.rb
101
+ - lib/yt/collections/branding_settings.rb
180
102
  - lib/yt/collections/bulk_report_jobs.rb
181
103
  - lib/yt/collections/bulk_reports.rb
104
+ - lib/yt/collections/captions.rb
105
+ - lib/yt/collections/channel_sections.rb
182
106
  - lib/yt/collections/channels.rb
183
107
  - lib/yt/collections/claim_histories.rb
184
108
  - lib/yt/collections/claims.rb
@@ -190,6 +114,7 @@ files:
190
114
  - lib/yt/collections/file_details.rb
191
115
  - lib/yt/collections/group_infos.rb
192
116
  - lib/yt/collections/group_items.rb
117
+ - lib/yt/collections/live_cuepoints.rb
193
118
  - lib/yt/collections/live_streaming_details.rb
194
119
  - lib/yt/collections/ownerships.rb
195
120
  - lib/yt/collections/partnered_channels.rb
@@ -230,9 +155,12 @@ files:
230
155
  - lib/yt/models/asset_snippet.rb
231
156
  - lib/yt/models/authentication.rb
232
157
  - lib/yt/models/base.rb
158
+ - lib/yt/models/branding_setting.rb
233
159
  - lib/yt/models/bulk_report.rb
234
160
  - lib/yt/models/bulk_report_job.rb
161
+ - lib/yt/models/caption.rb
235
162
  - lib/yt/models/channel.rb
163
+ - lib/yt/models/channel_section.rb
236
164
  - lib/yt/models/claim.rb
237
165
  - lib/yt/models/claim_event.rb
238
166
  - lib/yt/models/claim_history.rb
@@ -247,7 +175,7 @@ files:
247
175
  - lib/yt/models/group_info.rb
248
176
  - lib/yt/models/group_item.rb
249
177
  - lib/yt/models/id.rb
250
- - lib/yt/models/iterator.rb
178
+ - lib/yt/models/live_cuepoint.rb
251
179
  - lib/yt/models/live_streaming_detail.rb
252
180
  - lib/yt/models/match_policy.rb
253
181
  - lib/yt/models/ownership.rb
@@ -274,12 +202,11 @@ files:
274
202
  - lib/yt/models/video_group.rb
275
203
  - lib/yt/request.rb
276
204
  - lib/yt/version.rb
277
- - yt.gemspec
278
- homepage: http://github.com/Fullscreen/yt
205
+ homepage: http://github.com/nullscreen/yt
279
206
  licenses:
280
207
  - MIT
281
208
  metadata: {}
282
- post_install_message:
209
+ post_install_message:
283
210
  rdoc_options: []
284
211
  require_paths:
285
212
  - lib
@@ -287,15 +214,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
287
214
  requirements:
288
215
  - - ">="
289
216
  - !ruby/object:Gem::Version
290
- version: 1.9.3
217
+ version: '2.1'
291
218
  required_rubygems_version: !ruby/object:Gem::Requirement
292
219
  requirements:
293
220
  - - ">="
294
221
  - !ruby/object:Gem::Version
295
222
  version: '0'
296
223
  requirements: []
297
- rubygems_version: 3.1.2
298
- signing_key:
224
+ rubygems_version: 3.4.20
225
+ signing_key:
299
226
  specification_version: 4
300
227
  summary: Yt makes it easy to interact with Youtube V3 API by providing a modular,
301
228
  intuitive and tested Ruby-style API.
data/.gitignore DELETED
@@ -1,27 +0,0 @@
1
- # See http://help.github.com/ignore-files/ for more about ignoring files.
2
- #
3
- # If you find yourself ignoring temporary files generated by your text editor
4
- # or operating system, you probably want to add a global ignore instead:
5
- # git config --global core.excludesfile '~/.gitignore_global'
6
-
7
- # Ignore bundler config.
8
- /.bundle
9
-
10
- # Ignore the default SQLite database.
11
- /db/*.sqlite3
12
- /db/*.sqlite3-journal
13
-
14
- coverage/
15
- Gemfile.lock
16
-
17
- # Ignore all logfiles and tempfiles.
18
- /log/*.log
19
- /tmp
20
- **/tmp
21
- *.gem
22
- *.sqlite3
23
-
24
- doc/
25
- .yardoc/
26
- _site/
27
- TODO.md
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --exclude_pattern spec/requests/as_content_owner/*_spec.rb
3
- --tag=~slow
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- notifications:
3
- email: true
4
- matrix:
5
- include:
6
- - rvm: 2.6.3
7
- gemfile: gemfiles/Gemfile.activesupport-4.x
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in yt.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,11 +0,0 @@
1
- require "bundler"
2
- Bundler.setup
3
- Bundler::GemHelper.install_tasks
4
-
5
- require "rspec/core/rake_task"
6
- require "rspec/core/version"
7
-
8
- desc "Run all examples"
9
- RSpec::Core::RakeTask.new :spec
10
-
11
- task default: [:spec]
data/bin/yt DELETED
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- begin
4
- require 'yt'
5
- rescue LoadError
6
- require 'rubygems'
7
- require 'yt'
8
- end
9
-
10
- Yt.configuration.log_level = :debug
11
- id = ARGV[1] || 'rdwz7QiG0lk'
12
-
13
- case ARGV[0]
14
- when 'info'
15
- puts "Yt version #{Yt::VERSION}"
16
- video = Yt::Video.new id: id
17
- puts video.title
18
- when 'video'
19
- video = Yt::Video.new id: id
20
- views = "#{video.view_count} #{'view'.pluralize video.view_count}"
21
- likes = "#{video.like_count} #{'like'.pluralize video.like_count}"
22
- puts "'#{video.title}' by #{video.channel_title} has #{views} and #{likes}"
23
- end
@@ -1,4 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'activesupport', '~> 3.0'
4
- gemspec path: '../'
@@ -1,4 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'activesupport', '~> 4.0'
4
- gemspec path: '../'
@@ -1,16 +0,0 @@
1
- module Yt
2
- module Models
3
- # @private
4
- # If we dropped support for Ruby 1.9.3, then we could simply use Enumerator
5
- # which takes a `size` parameter in Ruby >= 2.
6
- class Iterator < Enumerator
7
- def initialize(size=nil, &block)
8
- RUBY_VERSION < '2' ? super(&block) : super(size, &block)
9
- end
10
-
11
- def size
12
- RUBY_VERSION < '2' ? count : super
13
- end
14
- end
15
- end
16
- end
data/yt.gemspec DELETED
@@ -1,36 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'yt/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "yt"
7
- spec.version = Yt::VERSION
8
- spec.authors = ["Claudio Baccigalupo"]
9
- spec.email = ["claudio@fullscreen.net"]
10
- spec.description = %q{Youtube V3 API client.}
11
- spec.summary = %q{Yt makes it easy to interact with Youtube V3 API by
12
- providing a modular, intuitive and tested Ruby-style API.}
13
- spec.homepage = "http://github.com/Fullscreen/yt"
14
- spec.license = "MIT"
15
-
16
- spec.required_ruby_version = '>= 1.9.3'
17
-
18
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
- end
21
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
- spec.require_paths = ["lib"]
24
-
25
- spec.add_dependency 'activesupport' # '3 (Ruby 1.9) or 4 (Ruby 2)'
26
-
27
- # For development / Code coverage / Documentation
28
- spec.add_development_dependency 'bundler' #, '~> 1.0'
29
- spec.add_development_dependency 'rspec' #, '~> 2.0'
30
- spec.add_development_dependency 'rake' #, '~> 10.0'
31
- spec.add_development_dependency 'yard' #, '~> 0.8.0'
32
- spec.add_development_dependency 'coveralls' #, '~> 0.7.0'
33
- spec.add_development_dependency 'pry'
34
- spec.add_development_dependency 'vcr'
35
- spec.add_development_dependency 'webmock'
36
- end