yt 0.33.4 → 0.34.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c89bfab3bb32975237aa1b79a1f0897a240ea494f3d3928a03b423c734b71f6
4
- data.tar.gz: 6c58ab20408d9fdf79265fc499d1ee0f88623295de50592a25948e8029aaf91a
3
+ metadata.gz: 33ad5cd77351556b82e952d8475b978539d34cb7b82731f60b91dc000fd675ce
4
+ data.tar.gz: 373db01c5faa0076ea61b9e30f81f7959505ea423026dcc2aba227f8f6aacc13
5
5
  SHA512:
6
- metadata.gz: 2bcd96aa69c14456e067f0cad222148743334e8d8f89f3a052923f687e2d06e3a53db772898ec43399d1cdff20352fc9e56f63745bdbbebe69641511255cf5a9
7
- data.tar.gz: 52245373b815ad681f7516bea9157597c7b5b118db206a50c7ca2746cf61b8c591f2fb4765c63787427cac26fb803ce11053c1d12855e4d213fdbfb54b372e0c
6
+ metadata.gz: 0cb261d97cba17e75a42c49420784917bea7a9f6c257f08f928463db81f34784fce53c844d5744c6e72001bb4a600b94cef6592fd2e8ebc368118c5bcec1cb5b
7
+ data.tar.gz: 8af926d7f3341c7f3ffdd1b6a71554470fcd13d6fa7710e666eacf2e9968c76efedb5cdbf603ab792c0f076497fafa8e64364cb2a8355ad6b4475218950069b6
data/CHANGELOG.md CHANGED
@@ -6,6 +6,19 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.34.0 - 2024-08-25
10
+
11
+ * Ruby 2.1+ required https://github.com/nullscreen/yt/pull/425
12
+ * [IMPROVEMENT] Use new oauth2 endpoints https://github.com/nullscreen/yt/pull/422
13
+ * [REMOVAL] Remove `Playlist#tags` as 'snippet.tags[]' deprecated https://github.com/nullscreen/yt/pull/421
14
+ * [FEATURE] Add captions associated with a video https://github.com/nullscreen/yt/pull/419
15
+ * [BUGFIX] Remove dependency on the deprecated open-uri in Ruby 3 https://github.com/nullscreen/yt/pull/412 (thank you @kalemi19)
16
+
17
+ **Breaking change**
18
+
19
+ If your code runs on version of Ruby 2.1 or earlier, it will not be supported.
20
+ Please make sure to upgrade Ruby version to later than 2.1 before upgrade Yt.
21
+
9
22
  ## 0.33.4 - 2021-01-15
10
23
 
11
24
  * [REMOVAL] remove retry for quota errors
data/README.md CHANGED
@@ -43,7 +43,7 @@ To install on your system, run
43
43
 
44
44
  To use inside a bundled Ruby project, add this line to the Gemfile:
45
45
 
46
- gem 'yt', '~> 0.32.0'
46
+ gem 'yt', '~> 0.34.0'
47
47
 
48
48
  Since the gem follows [Semantic Versioning](http://semver.org),
49
49
  indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
@@ -56,7 +56,7 @@ Available resources
56
56
  Yt::Account
57
57
  -----------
58
58
 
59
- Check [fullscreen.github.io/yt](http://fullscreen.github.io/yt/accounts.html) for the list of methods available for `Yt::Account`.
59
+ Check [nullscreen.github.io/yt](http://nullscreen.github.io/yt/accounts.html) for the list of methods available for `Yt::Account`.
60
60
 
61
61
 
62
62
  Yt::ContentOwner
@@ -109,22 +109,22 @@ content_owner.assets.first.custom_id #=> "MoKNJFOIRroc"
109
109
  Yt::Channel
110
110
  -----------
111
111
 
112
- Check [fullscreen.github.io/yt](http://fullscreen.github.io/yt/channels.html) for the list of methods available for `Yt::Channel`.
112
+ Check [nullscreen.github.io/yt](http://nullscreen.github.io/yt/channels.html) for the list of methods available for `Yt::Channel`.
113
113
 
114
114
  Yt::Video
115
115
  ---------
116
116
 
117
- Check [fullscreen.github.io/yt](http://fullscreen.github.io/yt/videos.html) for the list of methods available for `Yt::Video`.
117
+ Check [nullscreen.github.io/yt](http://nullscreen.github.io/yt/videos.html) for the list of methods available for `Yt::Video`.
118
118
 
119
119
  Yt::Playlist
120
120
  ------------
121
121
 
122
- Check [fullscreen.github.io/yt](http://fullscreen.github.io/yt/playlists.html) for the list of methods available for `Yt::Playlist`.
122
+ Check [nullscreen.github.io/yt](http://nullscreen.github.io/yt/playlists.html) for the list of methods available for `Yt::Playlist`.
123
123
 
124
124
  Yt::PlaylistItem
125
125
  ----------------
126
126
 
127
- Check [fullscreen.github.io/yt](http://fullscreen.github.io/yt/playlist_items.html) for the list of methods available for `Yt::PlaylistItem`.
127
+ Check [nullscreen.github.io/yt](http://nullscreen.github.io/yt/playlist_items.html) for the list of methods available for `Yt::PlaylistItem`.
128
128
 
129
129
  Yt::CommentThread
130
130
  ----------------
@@ -217,7 +217,7 @@ videos.where(id: 'jNQXAC9IVRw,invalid').map(&:title) #=> ["Fullscreen Creator Pl
217
217
  Yt::Annotation
218
218
  --------------
219
219
 
220
- Check [fullscreen.github.io/yt](http://fullscreen.github.io/yt/annotations.html) for the list of methods available for `Yt::Annotation`.
220
+ Check [nullscreen.github.io/yt](http://nullscreen.github.io/yt/annotations.html) for the list of methods available for `Yt::Annotation`.
221
221
 
222
222
 
223
223
  Yt::MatchPolicy
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "yt"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ require "pry"
12
+ Pry.start
13
+
14
+ # require "irb"
15
+ # IRB.start(__FILE__)
@@ -1,5 +1,4 @@
1
1
  require 'yt/request'
2
- require 'yt/models/iterator'
3
2
  require 'yt/errors/no_items'
4
3
  require 'yt/config'
5
4
 
@@ -17,7 +16,7 @@ module Yt
17
16
 
18
17
  def list
19
18
  @last_index, @page_token = 0, nil
20
- Yt::Iterator.new(-> {total_results}) do |items|
19
+ Enumerator.new(-> {total_results}) do |items|
21
20
  while next_item = find_next
22
21
  items << next_item
23
22
  end
@@ -32,6 +32,7 @@ module Yt
32
32
  @force = options[:force]
33
33
  @scopes = options[:scopes]
34
34
  @authentication = options[:authentication]
35
+ @state = options[:state]
35
36
  end
36
37
 
37
38
  def auth
@@ -48,7 +49,7 @@ module Yt
48
49
 
49
50
  def authentication_url
50
51
  host = 'accounts.google.com'
51
- path = '/o/oauth2/auth'
52
+ path = '/o/oauth2/v2/auth'
52
53
  query = authentication_url_params.to_param
53
54
  URI::HTTPS.build(host: host, path: path, query: query).to_s
54
55
  end
@@ -190,6 +191,7 @@ module Yt
190
191
  params[:access_type] = :offline
191
192
  params[:approval_prompt] = @force ? :force : :auto
192
193
  # params[:include_granted_scopes] = true
194
+ params[:state] = @state if @state
193
195
  end
194
196
  end
195
197
 
@@ -243,4 +245,4 @@ module Yt
243
245
  end
244
246
  end
245
247
  end
246
- end
248
+ end
@@ -16,8 +16,8 @@ module Yt
16
16
 
17
17
  def list_params
18
18
  super.tap do |params|
19
- params[:host] = 'accounts.google.com'
20
- params[:path] = '/o/oauth2/token'
19
+ params[:host] = 'oauth2.googleapis.com'
20
+ params[:path] = '/token'
21
21
  params[:request_format] = :form
22
22
  params[:method] = :post
23
23
  params[:auth] = nil
@@ -0,0 +1,30 @@
1
+ require 'yt/collections/base'
2
+
3
+ module Yt
4
+ module Collections
5
+ # Provides methods to interact with a collection of video captions.
6
+ class Captions < Resources
7
+
8
+ private
9
+
10
+ def attributes_for_new_item(data)
11
+ {id: data['id'], snippet: data['snippet'], auth: @auth}
12
+ end
13
+
14
+ def list_params
15
+ super.tap do |params|
16
+ params[:path] = "/youtube/v3/captions"
17
+ params[:params] = captions_params
18
+ end
19
+ end
20
+
21
+ def captions_params
22
+ {}.tap do |params|
23
+ params[:part] = 'snippet'
24
+ params[:video_id] = @parent.id if @parent
25
+ apply_where_params! params
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -15,9 +15,10 @@ module Yt
15
15
 
16
16
  def list_params
17
17
  super.tap do |params|
18
- params[:path] = '/o/oauth2/device/code'
18
+ params[:host] = 'oauth2.googleapis.com'
19
+ params[:path] = '/device/code'
19
20
  end
20
21
  end
21
22
  end
22
23
  end
23
- end
24
+ end
@@ -15,10 +15,10 @@ module Yt
15
15
 
16
16
  def list_params
17
17
  super.tap do |params|
18
- params[:host] = 'accounts.google.com'
19
- params[:path] = '/o/oauth2/revoke'
20
- params[:request_format] = nil
21
- params[:method] = :get
18
+ params[:host] = 'oauth2.googleapis.com'
19
+ params[:path] = '/revoke'
20
+ params[:request_format] = :form
21
+ params[:method] = :post
22
22
  params[:auth] = nil
23
23
  params[:body] = nil
24
24
  params[:camelize_body] = false
@@ -13,7 +13,7 @@ module Yt
13
13
  # @see https://developers.google.com/+/api/latest/people/getOpenIdConnect
14
14
  def list_params
15
15
  super.tap do |params|
16
- params[:path] = '/oauth2/v2/userinfo'
16
+ params[:path] = '/oauth2/v3/userinfo'
17
17
  params[:expected_response] = Net::HTTPOK
18
18
  end
19
19
  end
@@ -33,4 +33,4 @@ module Yt
33
33
  end
34
34
  end
35
35
  end
36
- end
36
+ end
@@ -1,4 +1,3 @@
1
- require 'open-uri'
2
1
  require 'yt/models/base'
3
2
 
4
3
  module Yt
@@ -70,7 +69,7 @@ module Yt
70
69
  # @option params [Boolean] :self_declared_made_for_kids The video’s made for kids self-declaration.
71
70
  # @return [Yt::Models::Video] the newly uploaded video.
72
71
  def upload_video(path_or_url, params = {})
73
- file = open path_or_url, 'rb'
72
+ file = URI.open(path_or_url)
74
73
  session = resumable_sessions.insert file.size, upload_body(params)
75
74
 
76
75
  session.update(body: file) do |data|
@@ -0,0 +1,19 @@
1
+ require 'yt/models/resource'
2
+
3
+ module Yt
4
+ module Models
5
+ # Provides methods to interact with YouTube video captions.
6
+ # @see https://developers.google.com/youtube/v3/docs/captions
7
+ class Caption < Resource
8
+
9
+ # @return [String] the ID used to identify the caption.
10
+ has_attribute :id
11
+
12
+ delegate :video_id, to: :snippet
13
+ delegate :last_updated, to: :snippet
14
+ delegate :language, to: :snippet
15
+ delegate :name, to: :snippet
16
+ delegate :status, to: :snippet
17
+ end
18
+ end
19
+ end
@@ -54,7 +54,7 @@ module Yt
54
54
  # @option params [String] :content_type The type of content being uploaded.
55
55
  # @return [Yt::Models::Reference] the newly uploaded reference.
56
56
  def upload_reference_file(path_or_url, params = {})
57
- file = open path_or_url, 'rb'
57
+ file = URI.open(path_or_url)
58
58
  session = resumable_sessions.insert file.size, params
59
59
 
60
60
  session.update(body: file) do |data|
@@ -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
@@ -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
@@ -533,6 +533,10 @@ module Yt
533
533
  # player that will play the video.
534
534
  delegate :embed_html, to: :player
535
535
 
536
+ ### CAPTION ###
537
+
538
+ has_many :captions
539
+
536
540
  ### ACTIONS (UPLOAD, UPDATE, DELETE) ###
537
541
 
538
542
  # Uploads a thumbnail
@@ -542,7 +546,7 @@ module Yt
542
546
  # @raise [Yt::Errors::RequestError] if path_or_url is not a valid path
543
547
  # or URL.
544
548
  def upload_thumbnail(path_or_url)
545
- file = open(path_or_url, 'rb') rescue StringIO.new
549
+ file = URI.open(path_or_url) rescue StringIO.new
546
550
  session = resumable_sessions.insert file.size
547
551
 
548
552
  session.update(body: file) do |data|
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.33.4'
2
+ VERSION = '0.34.0'
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.
data/yt.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "http://github.com/Fullscreen/yt"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.required_ruby_version = '>= 1.9.3'
16
+ spec.required_ruby_version = '>= 2.1'
17
17
 
18
18
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
19
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -22,14 +22,14 @@ Gem::Specification.new do |spec|
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency 'activesupport' # '3 (Ruby 1.9) or 4 (Ruby 2)'
25
+ spec.add_dependency 'activesupport'
26
26
 
27
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'
28
+ spec.add_development_dependency 'bundler'
29
+ spec.add_development_dependency 'rspec'
30
+ spec.add_development_dependency 'rake'
31
+ # spec.add_development_dependency 'yard'
32
+ # spec.add_development_dependency 'coveralls'
33
33
  spec.add_development_dependency 'pry'
34
34
  spec.add_development_dependency 'vcr'
35
35
  spec.add_development_dependency 'webmock'
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-15 00:00:00.000000000 Z
11
+ date: 2025-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -66,34 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
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
69
  - !ruby/object:Gem::Dependency
98
70
  name: pry
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -140,6 +112,7 @@ description: Youtube V3 API client.
140
112
  email:
141
113
  - claudio@fullscreen.net
142
114
  executables:
115
+ - console
143
116
  - yt
144
117
  extensions: []
145
118
  extra_rdoc_files: []
@@ -154,6 +127,7 @@ files:
154
127
  - README.md
155
128
  - Rakefile
156
129
  - YOUTUBE_IT.md
130
+ - bin/console
157
131
  - bin/yt
158
132
  - gemfiles/Gemfile.activesupport-3.x
159
133
  - gemfiles/Gemfile.activesupport-4.x
@@ -179,6 +153,7 @@ files:
179
153
  - lib/yt/collections/base.rb
180
154
  - lib/yt/collections/bulk_report_jobs.rb
181
155
  - lib/yt/collections/bulk_reports.rb
156
+ - lib/yt/collections/captions.rb
182
157
  - lib/yt/collections/channels.rb
183
158
  - lib/yt/collections/claim_histories.rb
184
159
  - lib/yt/collections/claims.rb
@@ -232,6 +207,7 @@ files:
232
207
  - lib/yt/models/base.rb
233
208
  - lib/yt/models/bulk_report.rb
234
209
  - lib/yt/models/bulk_report_job.rb
210
+ - lib/yt/models/caption.rb
235
211
  - lib/yt/models/channel.rb
236
212
  - lib/yt/models/claim.rb
237
213
  - lib/yt/models/claim_event.rb
@@ -247,7 +223,6 @@ files:
247
223
  - lib/yt/models/group_info.rb
248
224
  - lib/yt/models/group_item.rb
249
225
  - lib/yt/models/id.rb
250
- - lib/yt/models/iterator.rb
251
226
  - lib/yt/models/live_streaming_detail.rb
252
227
  - lib/yt/models/match_policy.rb
253
228
  - lib/yt/models/ownership.rb
@@ -279,7 +254,7 @@ homepage: http://github.com/Fullscreen/yt
279
254
  licenses:
280
255
  - MIT
281
256
  metadata: {}
282
- post_install_message:
257
+ post_install_message:
283
258
  rdoc_options: []
284
259
  require_paths:
285
260
  - lib
@@ -287,15 +262,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
287
262
  requirements:
288
263
  - - ">="
289
264
  - !ruby/object:Gem::Version
290
- version: 1.9.3
265
+ version: '2.1'
291
266
  required_rubygems_version: !ruby/object:Gem::Requirement
292
267
  requirements:
293
268
  - - ">="
294
269
  - !ruby/object:Gem::Version
295
270
  version: '0'
296
271
  requirements: []
297
- rubygems_version: 3.1.2
298
- signing_key:
272
+ rubygems_version: 3.5.22
273
+ signing_key:
299
274
  specification_version: 4
300
275
  summary: Yt makes it easy to interact with Youtube V3 API by providing a modular,
301
276
  intuitive and tested Ruby-style API.
@@ -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