yt 0.4.4 → 0.4.5
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 +4 -4
- data/.rspec +1 -0
- data/.travis.yml +13 -6
- data/Gemfile +0 -5
- data/Gemfile.lock +5 -20
- data/HISTORY.md +3 -1
- data/README.md +15 -15
- data/gemfiles/Gemfile.activesupport-3.x +4 -0
- data/gemfiles/Gemfile.activesupport-4.x +4 -0
- data/lib/yt/actions/delete.rb +2 -5
- data/lib/yt/actions/delete_all.rb +1 -2
- data/lib/yt/actions/insert.rb +2 -6
- data/lib/yt/actions/list.rb +2 -4
- data/lib/yt/{utils → actions}/request.rb +24 -27
- data/lib/yt/actions/request_error.rb +11 -0
- data/lib/yt/actions/update.rb +2 -5
- data/lib/yt/associations/annotations.rb +1 -1
- data/lib/yt/associations/channels.rb +1 -1
- data/lib/yt/associations/details_sets.rb +1 -1
- data/lib/yt/associations/playlist_items.rb +1 -1
- data/lib/yt/associations/playlists.rb +1 -1
- data/lib/yt/associations/ratings.rb +1 -1
- data/lib/yt/associations/snippets.rb +1 -1
- data/lib/yt/associations/subscriptions.rb +1 -1
- data/lib/yt/associations/user_infos.rb +1 -1
- data/lib/yt/associations/videos.rb +1 -1
- data/lib/yt/collections/annotations.rb +3 -12
- data/lib/yt/collections/channels.rb +2 -11
- data/lib/yt/collections/details_sets.rb +3 -12
- data/lib/yt/collections/playlist_items.rb +4 -13
- data/lib/yt/collections/playlists.rb +3 -12
- data/lib/yt/collections/ratings.rb +4 -13
- data/lib/yt/collections/resources.rb +16 -0
- data/lib/yt/collections/snippets.rb +5 -19
- data/lib/yt/collections/subscriptions.rb +6 -14
- data/lib/yt/collections/user_infos.rb +2 -11
- data/lib/yt/collections/videos.rb +4 -13
- data/lib/yt/models/annotation.rb +6 -1
- data/lib/yt/models/channel.rb +2 -10
- data/lib/yt/models/details_set.rb +5 -2
- data/lib/yt/models/playlist.rb +2 -12
- data/lib/yt/models/resource.rb +16 -0
- data/lib/yt/models/video.rb +4 -11
- data/lib/yt/version.rb +1 -1
- data/spec/collections/playlist_items_spec.rb +1 -1
- data/spec/models/annotation_spec.rb +7 -7
- data/spec/models/details_set_spec.rb +5 -0
- data/yt.gemspec +8 -6
- metadata +13 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: adb060424b5ef66ace1e77ddc760ec71bf568c07
|
|
4
|
+
data.tar.gz: 62e91a94a4e1af527360b217824ac2bdad530c0a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 742c01386c4e89187899dfbf544c34c5f2a4c513001cb03efc46434f03f35c56aa0fb2ea587566aa5b8419112f7aeaec8ad62abe8641e99e07e931ffa4b3f44e
|
|
7
|
+
data.tar.gz: d438cabdca24c141d39314b88d43453323a0c04a17afd0d6d1378e2f11ed8eb17f8841ae7d8d8597ad1654f7f783c093f4ff3d04a2b13e3370d49172b7e103c3
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
-
rvm:
|
|
3
|
-
- 2.0.0
|
|
4
2
|
notifications:
|
|
5
3
|
email: false
|
|
4
|
+
matrix:
|
|
5
|
+
include:
|
|
6
|
+
- rvm: 1.9.3
|
|
7
|
+
gemfile: gemfiles/Gemfile.activesupport-3.x
|
|
8
|
+
env:
|
|
9
|
+
- secure: DAvQ18qN71nRGkM+kOklTi6InE3dM98BgQAagve2S8/D76VXc+Hyl1It+/v73CrCuDdKTJpVl2a7pc+W5x+JG+PDo4X4ZXFURyvv417nywJulsda4y/TcTe59WHFGTQ/maj3l5PLPmENpROBU8/2HBGOSny0aNNkbnRXrTx3dU4=
|
|
10
|
+
- rvm: 2.0.0
|
|
11
|
+
gemfile: gemfiles/Gemfile.activesupport-4.x
|
|
12
|
+
env:
|
|
13
|
+
- secure: D57A44s/W77P3JLarTwELEjIeFtOKVcUtM2M7fKot6qfiDGF3azsWUoW0rrQG6hCUSop32UUeYQdnUmdhqWc89k0jtVKpW1I3UyV36iacKXevsfe/w6Q4CCHCi3udPVsEvt36ZQ2LtGMs0seUxujDaI1sqrfn3zMSXyVcSTjceg=
|
|
6
14
|
env:
|
|
7
15
|
global:
|
|
8
|
-
- secure:
|
|
9
|
-
- secure:
|
|
10
|
-
- secure:
|
|
11
|
-
- secure: RuYxzoTiam6GLIoP3xkhU9eaW3kjyxnOLYqBjjezhEHXrExDQinO5/k2NsHy2Y8iZSlKxMAG+DJJ45WAObNpg3fAPC/ExrzGyNX1u3qCQU481HbVZTJa8vg9IrJsSxCYyawdcbd7tgULiuRZacMmamsXLSJymLofF7LE0jA2KPA=
|
|
16
|
+
- secure: KFozlRmcSFzZIl8nXPZ5HIf+MAvgK4I7FYsTYyAMW7LsRJJ4NAJJCHAbWZUfmbqygUN188zj2y0TbQUu47lEf7v2XvJu6DFCYw+e4sk6lSW8V5jRzWl1f6DOKb1z+FBpUgJHj9OKykqjdtm3zVLWr56xm3fhB+ULDj8XVOVxyLk=
|
|
17
|
+
- secure: e/p7BLWhc8BBiXkxM3zXPj3x/8PqUT0ERRfUFYXAnZRZ0gmACtig590nZY7FLeNhBQMORuHt/ZE5DCuNZRaOIdauQqV4rP46U5CJBWe2RNzDi1L+nctUCSKDwVDIVl/r5yEP22om4g5s1xhWfc8wlJF2VEnfLcq80ca1vK+e1ds=
|
|
18
|
+
- secure: VpOIZVcckArwpoVs/fppUFEJEOI3e6zv2L5rP/vj0Uxl1hOHgg1emedjzM7x2wxKMi/L2g5ot9Oz6H9N1Y0FXzB1L49Hy3hla2nKBcecgvqk1z5InTpx6eiBDQqJAoZurCCmkdfKjVtWfb0CAdOX9Euio5DxqcnIcIVIiWpD5BE=
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
yt (0.4.
|
|
4
|
+
yt (0.4.5)
|
|
5
5
|
activesupport
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
activesupport (4.1.
|
|
10
|
+
activesupport (4.1.1)
|
|
11
11
|
i18n (~> 0.6, >= 0.6.9)
|
|
12
12
|
json (~> 1.7, >= 1.7.7)
|
|
13
13
|
minitest (~> 5.1)
|
|
14
14
|
thread_safe (~> 0.1)
|
|
15
15
|
tzinfo (~> 1.1)
|
|
16
|
-
coderay (1.1.0)
|
|
17
16
|
coveralls (0.7.0)
|
|
18
17
|
multi_json (~> 1.3)
|
|
19
18
|
rest-client
|
|
@@ -24,19 +23,9 @@ GEM
|
|
|
24
23
|
docile (1.1.3)
|
|
25
24
|
i18n (0.6.9)
|
|
26
25
|
json (1.8.1)
|
|
27
|
-
method_source (0.8.2)
|
|
28
26
|
mime-types (2.2)
|
|
29
27
|
minitest (5.3.3)
|
|
30
|
-
multi_json (1.
|
|
31
|
-
pry (0.9.12.6)
|
|
32
|
-
coderay (~> 1.0)
|
|
33
|
-
method_source (~> 0.8)
|
|
34
|
-
slop (~> 3.4)
|
|
35
|
-
pry-nav (0.2.3)
|
|
36
|
-
pry (~> 0.9.10)
|
|
37
|
-
pry-remote (0.1.8)
|
|
38
|
-
pry (~> 0.9)
|
|
39
|
-
slop (~> 3.0)
|
|
28
|
+
multi_json (1.10.0)
|
|
40
29
|
rake (10.3.1)
|
|
41
30
|
rest-client (1.6.7)
|
|
42
31
|
mime-types (>= 1.16)
|
|
@@ -53,12 +42,11 @@ GEM
|
|
|
53
42
|
multi_json
|
|
54
43
|
simplecov-html (~> 0.8.0)
|
|
55
44
|
simplecov-html (0.8.0)
|
|
56
|
-
slop (3.5.0)
|
|
57
45
|
term-ansicolor (1.3.0)
|
|
58
46
|
tins (~> 1.0)
|
|
59
47
|
thor (0.19.1)
|
|
60
48
|
thread_safe (0.3.3)
|
|
61
|
-
tins (1.
|
|
49
|
+
tins (1.2.0)
|
|
62
50
|
tzinfo (1.1.0)
|
|
63
51
|
thread_safe (~> 0.1)
|
|
64
52
|
yard (0.8.7.4)
|
|
@@ -67,11 +55,8 @@ PLATFORMS
|
|
|
67
55
|
ruby
|
|
68
56
|
|
|
69
57
|
DEPENDENCIES
|
|
70
|
-
bundler
|
|
58
|
+
bundler
|
|
71
59
|
coveralls
|
|
72
|
-
pry
|
|
73
|
-
pry-nav
|
|
74
|
-
pry-remote
|
|
75
60
|
rake
|
|
76
61
|
rspec
|
|
77
62
|
yard
|
data/HISTORY.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
v0.4
|
|
1
|
+
v0.4 - 2014/05/09
|
|
2
2
|
--------------------
|
|
3
3
|
|
|
4
4
|
* Complete rewrite, using ActiveSupport and separating models and collections
|
|
5
5
|
* New methods to handle annotations, details sets
|
|
6
|
+
* Supports also ActiveSupport 3 and Ruby 1.9.3 (not just AS4 + Ruby 2)
|
|
7
|
+
* Fix parsing annotation and timestamps longer than 1 hour
|
|
6
8
|
|
|
7
9
|
v0.3.0 - 2014/04/16
|
|
8
10
|
--------------------
|
data/README.md
CHANGED
|
@@ -4,12 +4,12 @@ Yt
|
|
|
4
4
|
Yt helps you write apps that need to interact with the YouTube API V3.
|
|
5
5
|
|
|
6
6
|
[](http://badge.fury.io/rb/yt)
|
|
7
|
-
[](https://gemnasium.com/fullscreeninc/yt)
|
|
8
|
+
[](https://travis-ci.org/fullscreeninc/yt)
|
|
9
|
+
[](https://coveralls.io/r/fullscreeninc/yt)
|
|
10
|
+
[](https://codeclimate.com/github/fullscreeninc/yt)
|
|
11
11
|
|
|
12
|
-
After [registering your app], you can run commands like:
|
|
12
|
+
After [registering your app](#registering-your-app), you can run commands like:
|
|
13
13
|
|
|
14
14
|
```ruby
|
|
15
15
|
channel = Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow'
|
|
@@ -33,7 +33,7 @@ Available resources
|
|
|
33
33
|
Yt::Account
|
|
34
34
|
-----------
|
|
35
35
|
|
|
36
|
-
Use [Yt::Account](
|
|
36
|
+
Use [Yt::Account](http://rubydoc.info/github/fullscreeninc/yt/master/Yt/Account) to:
|
|
37
37
|
|
|
38
38
|
* authenticate as a YouTube account
|
|
39
39
|
* read attributes of the account
|
|
@@ -52,7 +52,7 @@ account.channel #=> #<Yt::Channel @id=...>
|
|
|
52
52
|
Yt::Channel
|
|
53
53
|
-----------
|
|
54
54
|
|
|
55
|
-
Use [Yt::Channel](
|
|
55
|
+
Use [Yt::Channel](http://rubydoc.info/github/fullscreeninc/yt/master/Yt/Channel) to:
|
|
56
56
|
|
|
57
57
|
* read attributes of a channel
|
|
58
58
|
* access the videos of a channel
|
|
@@ -85,7 +85,7 @@ channel.delete_playlists title: 'New playlist' #=> [true]
|
|
|
85
85
|
Yt::Video
|
|
86
86
|
-----------
|
|
87
87
|
|
|
88
|
-
Use [Yt::Video](
|
|
88
|
+
Use [Yt::Video](http://rubydoc.info/github/fullscreeninc/yt/master/Yt/Video) to:
|
|
89
89
|
|
|
90
90
|
* read attributes of a video
|
|
91
91
|
* access the annotations of a video
|
|
@@ -110,7 +110,7 @@ video.like #=> true
|
|
|
110
110
|
Yt::Playlist
|
|
111
111
|
------------
|
|
112
112
|
|
|
113
|
-
Use [Yt::Playlist](
|
|
113
|
+
Use [Yt::Playlist](http://rubydoc.info/github/fullscreeninc/yt/master/Yt/Playlist) to:
|
|
114
114
|
|
|
115
115
|
* read attributes of a playlist
|
|
116
116
|
* access the items of a playlist
|
|
@@ -126,20 +126,20 @@ playlist.playlist_items.count #=> 1
|
|
|
126
126
|
playlist.playlist_items.first #=> #<Yt::PlaylistItem @id=...>
|
|
127
127
|
playlist.playlist_items.first.position #=> 0
|
|
128
128
|
playlist.playlist_items.first.video.title #=> "Fullscreen Creator Platform"
|
|
129
|
-
playlist.delete_playlist_items title: 'Fullscreen Creator Platform' #=> [true]
|
|
130
129
|
|
|
131
130
|
# An OAuth2 prompt will appear before the following commands
|
|
132
131
|
playlist.add_video 'MESycYJytkU'
|
|
133
132
|
playlist.add_videos ['MESycYJytkU', 'MESycYJytkU']
|
|
133
|
+
playlist.delete_playlist_items title: 'Fullscreen Creator Platform' #=> [true]
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
*Adding videos requires authentication (see below).*
|
|
136
|
+
*Adding and removing videos/items requires authentication (see below).*
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
Yt::Annotation
|
|
140
140
|
--------------
|
|
141
141
|
|
|
142
|
-
Use [Yt::Annotation](
|
|
142
|
+
Use [Yt::Annotation](http://rubydoc.info/github/fullscreeninc/yt/master/Yt/Annotation) to:
|
|
143
143
|
|
|
144
144
|
* read attributes of an annotation
|
|
145
145
|
|
|
@@ -204,7 +204,7 @@ refresh token, then add the following snippet of code to the initializer of your
|
|
|
204
204
|
|
|
205
205
|
```ruby
|
|
206
206
|
Yt.configure do |config|
|
|
207
|
-
config.client_id = '1234567890.apps.googleusercontent.com
|
|
207
|
+
config.client_id = '1234567890.apps.googleusercontent.com'
|
|
208
208
|
config.client_secret = '1234567890'
|
|
209
209
|
end
|
|
210
210
|
```
|
|
@@ -247,7 +247,7 @@ refresh token, then add the following snippet of code to the initializer of your
|
|
|
247
247
|
```ruby
|
|
248
248
|
Yt.configure do |config|
|
|
249
249
|
config.scenario = :device_app
|
|
250
|
-
config.client_id = '1234567890.apps.googleusercontent.com
|
|
250
|
+
config.client_id = '1234567890.apps.googleusercontent.com'
|
|
251
251
|
config.client_secret = '1234567890'
|
|
252
252
|
end
|
|
253
253
|
```
|
|
@@ -276,7 +276,7 @@ To install on your system, run
|
|
|
276
276
|
|
|
277
277
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
|
278
278
|
|
|
279
|
-
gem 'yt', '~> 0.4.
|
|
279
|
+
gem 'yt', '~> 0.4.5'
|
|
280
280
|
|
|
281
281
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
|
282
282
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
data/lib/yt/actions/delete.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'yt/
|
|
1
|
+
require 'yt/actions/request'
|
|
2
2
|
|
|
3
3
|
module Yt
|
|
4
4
|
module Actions
|
|
@@ -14,11 +14,8 @@ module Yt
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def delete_params
|
|
17
|
-
|
|
17
|
+
Request.default_params.tap do |params|
|
|
18
18
|
params[:method] = :delete
|
|
19
|
-
params[:format] = :json
|
|
20
|
-
params[:host] = 'www.googleapis.com'
|
|
21
|
-
params[:scope] = 'https://www.googleapis.com/auth/youtube'
|
|
22
19
|
params[:auth] = @auth
|
|
23
20
|
end
|
|
24
21
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'yt/actions/list'
|
|
2
|
-
require 'yt/
|
|
2
|
+
require 'yt/actions/request'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Actions
|
|
@@ -10,7 +10,6 @@ module Yt
|
|
|
10
10
|
|
|
11
11
|
def do_delete_all(params = {})
|
|
12
12
|
where(params).map do |item|
|
|
13
|
-
yield item if block_given?
|
|
14
13
|
item.delete
|
|
15
14
|
end.tap { @items = [] }
|
|
16
15
|
end
|
data/lib/yt/actions/insert.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'yt/
|
|
1
|
+
require 'yt/actions/request'
|
|
2
2
|
|
|
3
3
|
module Yt
|
|
4
4
|
module Actions
|
|
@@ -15,12 +15,8 @@ module Yt
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def insert_params
|
|
18
|
-
|
|
18
|
+
Request.default_params.tap do |params|
|
|
19
19
|
params[:method] = :post
|
|
20
|
-
params[:format] = :json
|
|
21
|
-
params[:host] = 'www.googleapis.com'
|
|
22
|
-
params[:body_type] = :json
|
|
23
|
-
params[:scope] = 'https://www.googleapis.com/auth/youtube'
|
|
24
20
|
params[:auth] = @auth
|
|
25
21
|
end
|
|
26
22
|
end
|
data/lib/yt/actions/list.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'yt/
|
|
1
|
+
require 'yt/actions/request'
|
|
2
2
|
|
|
3
3
|
module Yt
|
|
4
4
|
module Actions
|
|
@@ -53,10 +53,8 @@ module Yt
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def list_params
|
|
56
|
-
|
|
56
|
+
Request.default_params.tap do |params|
|
|
57
57
|
params[:method] = :get
|
|
58
|
-
params[:format] = :json
|
|
59
|
-
params[:host] = 'www.googleapis.com'
|
|
60
58
|
params[:auth] = @auth
|
|
61
59
|
end
|
|
62
60
|
end
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
require 'yt/config'
|
|
2
|
-
|
|
3
|
-
require 'uri' # for URI.json
|
|
4
1
|
require 'net/http' # for Net::HTTP.start
|
|
2
|
+
require 'uri' # for URI.json
|
|
5
3
|
require 'json' # for JSON.parse
|
|
6
|
-
require 'active_support/core_ext
|
|
4
|
+
require 'active_support/core_ext' # for Hash.from_xml, Hash.to_param
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def reasons
|
|
11
|
-
error.fetch('errors', []).map{|e| e['reason']}
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def error
|
|
15
|
-
eval(message)['error'] rescue {}
|
|
16
|
-
end
|
|
17
|
-
end
|
|
6
|
+
require 'yt/actions/request_error'
|
|
7
|
+
require 'yt/config'
|
|
18
8
|
|
|
9
|
+
module Yt
|
|
19
10
|
class Request
|
|
20
11
|
def initialize(options = {})
|
|
21
12
|
options[:query] ||= options[:params].to_param
|
|
@@ -33,10 +24,17 @@ module Yt
|
|
|
33
24
|
add_authorization_to_request!
|
|
34
25
|
fetch_response.tap do |response|
|
|
35
26
|
response.body = parse_format response.body if response.body
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
# puts "You can try again running #{to_curl}"
|
|
28
|
+
raise RequestError, response.body unless response.is_a? Net::HTTPSuccess
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.default_params
|
|
33
|
+
{}.tap do |params|
|
|
34
|
+
params[:format] = :json
|
|
35
|
+
params[:host] = 'www.googleapis.com'
|
|
36
|
+
params[:scope] = 'https://www.googleapis.com/auth/youtube'
|
|
37
|
+
params[:body_type] = :json
|
|
40
38
|
end
|
|
41
39
|
end
|
|
42
40
|
|
|
@@ -55,19 +53,18 @@ module Yt
|
|
|
55
53
|
def fetch_response
|
|
56
54
|
Net::HTTP.start(@uri.host, @uri.port, use_ssl: true) do |http|
|
|
57
55
|
klass = "Net::HTTP::#{@method.capitalize}".constantize
|
|
58
|
-
request =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
request = klass.new @uri.request_uri
|
|
57
|
+
case @body_type
|
|
58
|
+
when :json
|
|
59
|
+
request.initialize_http_header 'Content-Type' => 'application/json'
|
|
60
|
+
request.initialize_http_header 'Content-length' => '0' unless @body
|
|
61
|
+
request.body = @body.to_json if @body
|
|
62
|
+
when :form
|
|
63
|
+
request.set_form_data @body if @body
|
|
62
64
|
end
|
|
63
65
|
@headers.each{|k,v| request.add_field k, v}
|
|
64
|
-
case @body_type
|
|
65
|
-
when :json then request.body = @body.to_json
|
|
66
|
-
when :form then request.set_form_data @body
|
|
67
|
-
end if @body
|
|
68
66
|
|
|
69
67
|
http.request request
|
|
70
|
-
# NOTE! Here refresh the token if the access is expired
|
|
71
68
|
end
|
|
72
69
|
end
|
|
73
70
|
|
data/lib/yt/actions/update.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'yt/
|
|
1
|
+
require 'yt/actions/request'
|
|
2
2
|
|
|
3
3
|
module Yt
|
|
4
4
|
module Actions
|
|
@@ -12,11 +12,8 @@ module Yt
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def update_params
|
|
15
|
-
|
|
15
|
+
Request.default_params.tap do |params|
|
|
16
16
|
params[:method] = :put
|
|
17
|
-
params[:format] = :json
|
|
18
|
-
params[:host] = 'www.googleapis.com'
|
|
19
|
-
params[:scope] = 'https://www.googleapis.com/auth/youtube'
|
|
20
17
|
params[:auth] = @auth
|
|
21
18
|
end
|
|
22
19
|
end
|
|
@@ -7,7 +7,7 @@ module Yt
|
|
|
7
7
|
# YouTube resources with playlist items are: playlists.
|
|
8
8
|
module PlaylistItems
|
|
9
9
|
def playlist_items
|
|
10
|
-
@playlist_items ||= Collections::PlaylistItems.
|
|
10
|
+
@playlist_items ||= Collections::PlaylistItems.of self
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def add_video(video_id)
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
require 'yt/collections/
|
|
1
|
+
require 'yt/collections/resources'
|
|
2
2
|
require 'yt/models/annotation'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class Annotations <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@video = options[:video]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.by_video(video)
|
|
14
|
-
new video: video, auth: video.auth
|
|
15
|
-
end
|
|
6
|
+
class Annotations < Resources
|
|
16
7
|
|
|
17
8
|
private
|
|
18
9
|
|
|
@@ -25,7 +16,7 @@ module Yt
|
|
|
25
16
|
params[:format] = :xml
|
|
26
17
|
params[:host] = 'www.youtube.com'
|
|
27
18
|
params[:path] = '/annotations_invideo'
|
|
28
|
-
params[:params] = {video_id: @
|
|
19
|
+
params[:params] = {video_id: @parent.id}
|
|
29
20
|
end
|
|
30
21
|
end
|
|
31
22
|
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
require 'yt/collections/
|
|
1
|
+
require 'yt/collections/resources'
|
|
2
2
|
require 'yt/models/channel'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class Channels <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@account = options[:account]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.by_account(account)
|
|
14
|
-
new account: account, auth: account.auth
|
|
15
|
-
end
|
|
6
|
+
class Channels < Resources
|
|
16
7
|
|
|
17
8
|
private
|
|
18
9
|
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
require 'yt/collections/
|
|
1
|
+
require 'yt/collections/resources'
|
|
2
2
|
require 'yt/models/details_set'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class DetailsSets <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@video = options[:video]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.by_video(video)
|
|
14
|
-
new video: video, auth: video.auth
|
|
15
|
-
end
|
|
6
|
+
class DetailsSets < Resources
|
|
16
7
|
|
|
17
8
|
private
|
|
18
9
|
|
|
@@ -22,7 +13,7 @@ module Yt
|
|
|
22
13
|
|
|
23
14
|
def list_params
|
|
24
15
|
super.tap do |params|
|
|
25
|
-
params[:params] = {maxResults: 50, part: 'contentDetails', id: @
|
|
16
|
+
params[:params] = {maxResults: 50, part: 'contentDetails', id: @parent.id}
|
|
26
17
|
params[:scope] = 'https://www.googleapis.com/auth/youtube.readonly'
|
|
27
18
|
params[:path] = '/youtube/v3/videos'
|
|
28
19
|
end
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
require 'yt/collections/
|
|
1
|
+
require 'yt/collections/resources'
|
|
2
2
|
require 'yt/models/playlist_item'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class PlaylistItems <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@playlist = options[:playlist]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.by_playlist(playlist)
|
|
14
|
-
new playlist: playlist, auth: playlist.auth
|
|
15
|
-
end
|
|
6
|
+
class PlaylistItems < Resources
|
|
16
7
|
|
|
17
8
|
# options are id and kind
|
|
18
9
|
def insert(options = {}) #
|
|
19
10
|
resource = {kind: "youtube##{options[:kind]}"}
|
|
20
11
|
resource["#{options[:kind]}Id"] = options[:id]
|
|
21
|
-
snippet = {playlistId: @
|
|
12
|
+
snippet = {playlistId: @parent.id, resourceId: resource}
|
|
22
13
|
do_insert body: {snippet: snippet}, params: {part: 'snippet,status'}
|
|
23
14
|
end
|
|
24
15
|
|
|
@@ -34,7 +25,7 @@ module Yt
|
|
|
34
25
|
|
|
35
26
|
def list_params
|
|
36
27
|
super.tap do |params|
|
|
37
|
-
params[:params] = {maxResults: 50, part: 'snippet,status', playlistId: @
|
|
28
|
+
params[:params] = {maxResults: 50, part: 'snippet,status', playlistId: @parent.id}
|
|
38
29
|
params[:scope] = 'https://www.googleapis.com/auth/youtube.readonly'
|
|
39
30
|
params[:path] = '/youtube/v3/playlistItems'
|
|
40
31
|
end
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
require 'yt/collections/
|
|
1
|
+
require 'yt/collections/resources'
|
|
2
2
|
require 'yt/models/playlist'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class Playlists <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@channel = options[:channel]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.by_channel(channel)
|
|
14
|
-
new channel: channel, auth: channel.auth
|
|
15
|
-
end
|
|
6
|
+
class Playlists < Resources
|
|
16
7
|
|
|
17
8
|
# Valid body (no defaults) are: title (string), description (string), privacy_status (string),
|
|
18
9
|
# tags (array of strings)
|
|
@@ -40,7 +31,7 @@ module Yt
|
|
|
40
31
|
|
|
41
32
|
def list_params
|
|
42
33
|
super.tap do |params|
|
|
43
|
-
params[:params] = {maxResults: 50, part: 'snippet,status', channelId: @
|
|
34
|
+
params[:params] = {maxResults: 50, part: 'snippet,status', channelId: @parent.id}
|
|
44
35
|
params[:scope] = 'https://www.googleapis.com/auth/youtube.readonly'
|
|
45
36
|
params[:path] = '/youtube/v3/playlists'
|
|
46
37
|
end
|
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
require 'yt/collections/
|
|
1
|
+
require 'yt/collections/resources'
|
|
2
2
|
require 'yt/models/rating'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class Ratings <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@video = options[:video]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.by_video(video)
|
|
14
|
-
new video: video, auth: video.auth
|
|
15
|
-
end
|
|
6
|
+
class Ratings < Resources
|
|
16
7
|
|
|
17
8
|
private
|
|
18
9
|
|
|
19
10
|
def new_item(data)
|
|
20
|
-
Yt::Rating.new rating: data['rating'], video_id: @
|
|
11
|
+
Yt::Rating.new rating: data['rating'], video_id: @parent.id, auth: @auth
|
|
21
12
|
end
|
|
22
13
|
|
|
23
14
|
def list_params
|
|
24
15
|
super.tap do |params|
|
|
25
16
|
params[:path] = '/youtube/v3/videos/getRating'
|
|
26
|
-
params[:params] = {id: @
|
|
17
|
+
params[:params] = {id: @parent.id}
|
|
27
18
|
params[:scope] = 'https://www.googleapis.com/auth/youtube'
|
|
28
19
|
end
|
|
29
20
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'yt/collections/base'
|
|
2
|
+
|
|
3
|
+
module Yt
|
|
4
|
+
module Collections
|
|
5
|
+
class Resources < Base
|
|
6
|
+
def initialize(options = {})
|
|
7
|
+
@parent = options[:parent]
|
|
8
|
+
@auth = options[:auth]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.of(parent)
|
|
12
|
+
new parent: parent, auth: parent.auth
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
require 'yt/collections/
|
|
1
|
+
require 'yt/collections/resources'
|
|
2
2
|
require 'yt/models/snippet'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class Snippets <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@resource = options[:resource]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# @note Google API must have some caching layer by which if we try to
|
|
14
|
-
# delete a snippet that we just created, we encounter an error.
|
|
15
|
-
# To overcome this, if we have just updated the snippet, we must
|
|
16
|
-
# wait some time before requesting it again.
|
|
17
|
-
#
|
|
18
|
-
def self.by_resource(resource)
|
|
19
|
-
new resource: resource, auth: resource.auth
|
|
20
|
-
end
|
|
6
|
+
class Snippets < Resources
|
|
21
7
|
|
|
22
8
|
private
|
|
23
9
|
|
|
@@ -26,11 +12,11 @@ module Yt
|
|
|
26
12
|
end
|
|
27
13
|
|
|
28
14
|
def list_params
|
|
29
|
-
|
|
15
|
+
parents_path = @parent.class.to_s.demodulize.underscore.pluralize
|
|
30
16
|
super.tap do |params|
|
|
31
|
-
params[:params] = {id: @
|
|
17
|
+
params[:params] = {id: @parent.id, part: 'snippet'}
|
|
32
18
|
params[:scope] = 'https://www.googleapis.com/auth/youtube.readonly'
|
|
33
|
-
params[:path] = "/youtube/v3/#{
|
|
19
|
+
params[:path] = "/youtube/v3/#{parents_path}"
|
|
34
20
|
end
|
|
35
21
|
end
|
|
36
22
|
end
|
|
@@ -3,16 +3,7 @@ require 'yt/models/subscription'
|
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class Subscriptions <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@channel = options[:channel]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.by_channel(channel)
|
|
14
|
-
new channel: channel, auth: channel.auth
|
|
15
|
-
end
|
|
6
|
+
class Subscriptions < Resources
|
|
16
7
|
|
|
17
8
|
def insert(options = {})
|
|
18
9
|
throttle
|
|
@@ -22,7 +13,8 @@ module Yt
|
|
|
22
13
|
end
|
|
23
14
|
|
|
24
15
|
def delete_all(params = {}, options = {})
|
|
25
|
-
|
|
16
|
+
throttle
|
|
17
|
+
do_delete_all params
|
|
26
18
|
end
|
|
27
19
|
|
|
28
20
|
private
|
|
@@ -36,7 +28,7 @@ module Yt
|
|
|
36
28
|
# To overcome this, if we have just updated the subscription, we must
|
|
37
29
|
# wait some time before requesting it again.
|
|
38
30
|
#
|
|
39
|
-
def throttle(seconds =
|
|
31
|
+
def throttle(seconds = 9)
|
|
40
32
|
@last_changed_at ||= Time.now - seconds
|
|
41
33
|
wait = [@last_changed_at - Time.now + seconds, 0].max
|
|
42
34
|
sleep wait
|
|
@@ -50,7 +42,7 @@ module Yt
|
|
|
50
42
|
|
|
51
43
|
def list_params
|
|
52
44
|
super.tap do |params|
|
|
53
|
-
params[:params] = {maxResults: 50, forChannelId: @
|
|
45
|
+
params[:params] = {maxResults: 50, forChannelId: @parent.id, mine: true, part: 'snippet'}
|
|
54
46
|
params[:scope] = 'https://www.googleapis.com/auth/youtube'
|
|
55
47
|
params[:path] = '/youtube/v3/subscriptions'
|
|
56
48
|
end
|
|
@@ -60,7 +52,7 @@ module Yt
|
|
|
60
52
|
super.tap do |params|
|
|
61
53
|
params[:path] = '/youtube/v3/subscriptions'
|
|
62
54
|
params[:params] = {part: 'snippet'}
|
|
63
|
-
params[:body] = {snippet: {resourceId: {channelId: @
|
|
55
|
+
params[:body] = {snippet: {resourceId: {channelId: @parent.id}}}
|
|
64
56
|
end
|
|
65
57
|
end
|
|
66
58
|
end
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
require 'yt/collections/
|
|
1
|
+
require 'yt/collections/resources'
|
|
2
2
|
require 'yt/models/user_info'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class UserInfos <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@account = options[:account]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.by_account(account)
|
|
14
|
-
new account: account, auth: account.auth
|
|
15
|
-
end
|
|
6
|
+
class UserInfos < Resources
|
|
16
7
|
|
|
17
8
|
private
|
|
18
9
|
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
require 'yt/collections/
|
|
1
|
+
require 'yt/collections/resources'
|
|
2
2
|
require 'yt/models/video'
|
|
3
3
|
|
|
4
4
|
module Yt
|
|
5
5
|
module Collections
|
|
6
|
-
class Videos <
|
|
7
|
-
|
|
8
|
-
def initialize(options = {})
|
|
9
|
-
@channel = options[:channel]
|
|
10
|
-
@auth = options[:auth]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def self.by_channel(channel)
|
|
14
|
-
new channel: channel, auth: channel.auth
|
|
15
|
-
end
|
|
6
|
+
class Videos < Resources
|
|
16
7
|
|
|
17
8
|
private
|
|
18
9
|
|
|
@@ -22,8 +13,8 @@ module Yt
|
|
|
22
13
|
|
|
23
14
|
def list_params
|
|
24
15
|
super.tap do |params|
|
|
25
|
-
params[:params] = {channelId: @
|
|
26
|
-
params[:scope] = 'https://www.googleapis.com/auth/youtube'
|
|
16
|
+
params[:params] = {channelId: @parent.id, type: :video, maxResults: 50, part: 'snippet'}
|
|
17
|
+
params[:scope] = 'https://www.googleapis.com/auth/youtube.readonly'
|
|
27
18
|
params[:path] = '/youtube/v3/search'
|
|
28
19
|
end
|
|
29
20
|
end
|
data/lib/yt/models/annotation.rb
CHANGED
|
@@ -118,7 +118,12 @@ module Yt
|
|
|
118
118
|
|
|
119
119
|
def timestamps
|
|
120
120
|
@timestamps ||= positions.map do |pos|
|
|
121
|
-
|
|
121
|
+
regex = %r{(?:|(?<hours>\d*):)(?:|(?<min>\d*):)(?<sec>\d*)\.(?<ms>\d*)}
|
|
122
|
+
match = pos['t'].match regex
|
|
123
|
+
hours = (match[:hours] || '0').to_i
|
|
124
|
+
minutes = (match[:min] || '0').to_i
|
|
125
|
+
seconds = (match[:sec]).to_i
|
|
126
|
+
(hours * 60 + minutes) * 60 + seconds
|
|
122
127
|
end
|
|
123
128
|
end
|
|
124
129
|
|
data/lib/yt/models/channel.rb
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
require 'yt/models/
|
|
1
|
+
require 'yt/models/resource'
|
|
2
2
|
|
|
3
3
|
module Yt
|
|
4
|
-
class Channel <
|
|
5
|
-
attr_reader :id, :auth
|
|
6
|
-
has_one :snippet, delegate: [:title, :description, :thumbnail_url, :published_at]
|
|
4
|
+
class Channel < Resource
|
|
7
5
|
has_many :subscriptions
|
|
8
6
|
has_many :videos
|
|
9
7
|
has_many :playlists
|
|
10
|
-
|
|
11
|
-
def initialize(options = {})
|
|
12
|
-
@id = options[:id]
|
|
13
|
-
@auth = options[:auth]
|
|
14
|
-
@snippet = Snippet.new(data: options[:snippet]) if options[:snippet]
|
|
15
|
-
end
|
|
16
8
|
end
|
|
17
9
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'yt/models/base'
|
|
2
|
+
|
|
1
3
|
module Yt
|
|
2
4
|
class DetailsSet < Base
|
|
3
5
|
|
|
@@ -22,10 +24,11 @@ module Yt
|
|
|
22
24
|
# of minutes (or seconds) of the video. For example, a value of PT15M51S indicates
|
|
23
25
|
# that the video is 15 minutes and 51 seconds long.
|
|
24
26
|
def to_seconds(iso8601_duration)
|
|
25
|
-
match = iso8601_duration.match %r{^PT(?:|(?<min>\d*?)M)(?:|(?<sec>\d*?)S)$}
|
|
27
|
+
match = iso8601_duration.match %r{^PT(?:|(?<hours>\d*?)H)(?:|(?<min>\d*?)M)(?:|(?<sec>\d*?)S)$}
|
|
28
|
+
hours = (match[:hours] || '0').to_i
|
|
26
29
|
minutes = (match[:min] || '0').to_i
|
|
27
30
|
seconds = (match[:sec]).to_i
|
|
28
|
-
minutes * 60 + seconds
|
|
31
|
+
(hours * 60 + minutes) * 60 + seconds
|
|
29
32
|
end
|
|
30
33
|
end
|
|
31
34
|
end
|
data/lib/yt/models/playlist.rb
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
require 'yt/models/
|
|
1
|
+
require 'yt/models/resource'
|
|
2
2
|
|
|
3
3
|
module Yt
|
|
4
|
-
class Playlist <
|
|
5
|
-
attr_reader :id, :auth
|
|
6
|
-
has_one :snippet, delegate: [:title, :description, :tags, :thumbnail_url, :published_at]
|
|
7
|
-
has_one :status, delegate: [:privacy_status, :public?, :private?, :unlisted?]
|
|
4
|
+
class Playlist < Resource
|
|
8
5
|
has_many :playlist_items
|
|
9
6
|
|
|
10
|
-
def initialize(options = {})
|
|
11
|
-
@id = options[:id]
|
|
12
|
-
@snippet = Snippet.new(data: options[:snippet]) if options[:snippet]
|
|
13
|
-
@status = Status.new(data: options[:status]) if options[:status]
|
|
14
|
-
@auth = options[:auth]
|
|
15
|
-
end
|
|
16
|
-
|
|
17
7
|
def delete
|
|
18
8
|
do_delete {@id = nil}
|
|
19
9
|
!exists?
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'yt/models/base'
|
|
2
|
+
|
|
3
|
+
module Yt
|
|
4
|
+
class Resource < Base
|
|
5
|
+
attr_reader :id, :auth
|
|
6
|
+
has_one :snippet, delegate: [:title, :description, :thumbnail_url, :published_at]
|
|
7
|
+
has_one :status, delegate: [:privacy_status, :public?, :private?, :unlisted?]
|
|
8
|
+
|
|
9
|
+
def initialize(options = {})
|
|
10
|
+
@id = options[:id]
|
|
11
|
+
@auth = options[:auth]
|
|
12
|
+
@snippet = Snippet.new(data: options[:snippet]) if options[:snippet]
|
|
13
|
+
@status = Status.new(data: options[:status]) if options[:status]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/yt/models/video.rb
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
+
require 'yt/models/resource'
|
|
2
|
+
|
|
1
3
|
module Yt
|
|
2
|
-
class Video <
|
|
3
|
-
has_many :annotations
|
|
4
|
+
class Video < Resource
|
|
4
5
|
has_one :details_set, delegate: [:duration]
|
|
5
6
|
has_one :rating
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
attr_reader :id, :auth
|
|
9
|
-
|
|
10
|
-
def initialize(options = {})
|
|
11
|
-
@id = options[:id]
|
|
12
|
-
@auth = options[:auth]
|
|
13
|
-
@snippet = Snippet.new(data: options[:snippet]) if options[:snippet]
|
|
14
|
-
end
|
|
7
|
+
has_many :annotations
|
|
15
8
|
end
|
|
16
9
|
end
|
data/lib/yt/version.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'yt/models/playlist'
|
|
|
3
3
|
require 'yt/collections/playlist_items'
|
|
4
4
|
|
|
5
5
|
describe Yt::Collections::PlaylistItems do
|
|
6
|
-
subject(:collection) { Yt::Collections::PlaylistItems.new
|
|
6
|
+
subject(:collection) { Yt::Collections::PlaylistItems.new parent: playlist }
|
|
7
7
|
let(:playlist) { Yt::Playlist.new }
|
|
8
8
|
|
|
9
9
|
describe '#insert' do
|
|
@@ -107,19 +107,19 @@ describe Yt::Annotation do
|
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
describe '#starts_after and #starts_before' do
|
|
110
|
-
context 'given an annotation with the first timestamp equal to
|
|
110
|
+
context 'given an annotation with the first timestamp equal to 1 hour' do
|
|
111
111
|
let(:xml) { %Q{
|
|
112
112
|
<segment>
|
|
113
113
|
<movingRegion type="rect">
|
|
114
|
-
<rectRegion d="0" h="17.7779998779" t="
|
|
115
|
-
<rectRegion d="0" h="17.7779998779" t="
|
|
114
|
+
<rectRegion d="0" h="17.7779998779" t="01:00:01.000" w="25.0" x="7.117000103" y="5.07000017166"/>
|
|
115
|
+
<rectRegion d="0" h="17.7779998779" t="01:05:56.066" w="25.0" x="7.117000103" y="5.07000017166"/>
|
|
116
116
|
</movingRegion>
|
|
117
117
|
</segment>
|
|
118
118
|
} }
|
|
119
|
-
it { expect(annotation.starts_after?
|
|
120
|
-
it { expect(annotation.starts_after?
|
|
121
|
-
it { expect(annotation.starts_before?
|
|
122
|
-
it { expect(annotation.starts_before?
|
|
119
|
+
it { expect(annotation.starts_after? 3600).to be_true }
|
|
120
|
+
it { expect(annotation.starts_after? 3610).to be_false }
|
|
121
|
+
it { expect(annotation.starts_before? 3600).to be_false }
|
|
122
|
+
it { expect(annotation.starts_before? 3610).to be_true }
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
context 'given an annotation without timestamps' do
|
|
@@ -5,6 +5,11 @@ describe Yt::DetailsSet do
|
|
|
5
5
|
subject(:details_set) { Yt::DetailsSet.new data: data }
|
|
6
6
|
|
|
7
7
|
describe '#duration' do
|
|
8
|
+
context 'given a details_set with duration in hours, minutes, seconds' do
|
|
9
|
+
let(:data) { {"duration"=>"PT1H18M52S"} }
|
|
10
|
+
it { expect(details_set.duration).to eq 4732 }
|
|
11
|
+
end
|
|
12
|
+
|
|
8
13
|
context 'given a details_set with duration in minutes and seconds' do
|
|
9
14
|
let(:data) { {"duration"=>"PT2M51S"} }
|
|
10
15
|
it { expect(details_set.duration).to eq 171 }
|
data/yt.gemspec
CHANGED
|
@@ -14,17 +14,19 @@ Gem::Specification.new do |spec|
|
|
|
14
14
|
spec.homepage = "http://github.com/fullscreeninc/yt"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
|
17
|
+
spec.required_ruby_version = '>= 1.9.3'
|
|
18
|
+
|
|
17
19
|
spec.files = `git ls-files`.split($/)
|
|
18
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
19
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
22
|
spec.require_paths = ["lib"]
|
|
21
23
|
|
|
22
|
-
spec.add_dependency 'activesupport' #
|
|
24
|
+
spec.add_dependency 'activesupport' # '3 (Ruby 1.9) or 4 (Ruby 2)'
|
|
23
25
|
|
|
24
26
|
# For development / Code coverage / Documentation
|
|
25
|
-
spec.add_development_dependency 'bundler'
|
|
26
|
-
spec.add_development_dependency 'rspec'
|
|
27
|
-
spec.add_development_dependency 'rake'
|
|
28
|
-
spec.add_development_dependency 'yard'
|
|
29
|
-
spec.add_development_dependency 'coveralls'
|
|
27
|
+
spec.add_development_dependency 'bundler' #, '~> 1.0'
|
|
28
|
+
spec.add_development_dependency 'rspec' #, '~> 2.0'
|
|
29
|
+
spec.add_development_dependency 'rake' #, '~> 10.0'
|
|
30
|
+
spec.add_development_dependency 'yard' #, '~> 0.8.0'
|
|
31
|
+
spec.add_development_dependency 'coveralls' #, '~> 0.7.0'
|
|
30
32
|
end
|
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.4.
|
|
4
|
+
version: 0.4.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Claudio Baccigalupo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-05-
|
|
11
|
+
date: 2014-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -28,16 +28,16 @@ dependencies:
|
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -114,11 +114,15 @@ files:
|
|
|
114
114
|
- Rakefile
|
|
115
115
|
- TODO.md
|
|
116
116
|
- bin/yt
|
|
117
|
+
- gemfiles/Gemfile.activesupport-3.x
|
|
118
|
+
- gemfiles/Gemfile.activesupport-4.x
|
|
117
119
|
- lib/yt.rb
|
|
118
120
|
- lib/yt/actions/delete.rb
|
|
119
121
|
- lib/yt/actions/delete_all.rb
|
|
120
122
|
- lib/yt/actions/insert.rb
|
|
121
123
|
- lib/yt/actions/list.rb
|
|
124
|
+
- lib/yt/actions/request.rb
|
|
125
|
+
- lib/yt/actions/request_error.rb
|
|
122
126
|
- lib/yt/actions/update.rb
|
|
123
127
|
- lib/yt/associations.rb
|
|
124
128
|
- lib/yt/associations/annotations.rb
|
|
@@ -139,6 +143,7 @@ files:
|
|
|
139
143
|
- lib/yt/collections/playlist_items.rb
|
|
140
144
|
- lib/yt/collections/playlists.rb
|
|
141
145
|
- lib/yt/collections/ratings.rb
|
|
146
|
+
- lib/yt/collections/resources.rb
|
|
142
147
|
- lib/yt/collections/snippets.rb
|
|
143
148
|
- lib/yt/collections/subscriptions.rb
|
|
144
149
|
- lib/yt/collections/user_infos.rb
|
|
@@ -154,12 +159,12 @@ files:
|
|
|
154
159
|
- lib/yt/models/playlist.rb
|
|
155
160
|
- lib/yt/models/playlist_item.rb
|
|
156
161
|
- lib/yt/models/rating.rb
|
|
162
|
+
- lib/yt/models/resource.rb
|
|
157
163
|
- lib/yt/models/snippet.rb
|
|
158
164
|
- lib/yt/models/status.rb
|
|
159
165
|
- lib/yt/models/subscription.rb
|
|
160
166
|
- lib/yt/models/user_info.rb
|
|
161
167
|
- lib/yt/models/video.rb
|
|
162
|
-
- lib/yt/utils/request.rb
|
|
163
168
|
- lib/yt/version.rb
|
|
164
169
|
- spec/associations/device_auth/channels_spec.rb
|
|
165
170
|
- spec/associations/device_auth/details_sets_spec.rb
|
|
@@ -218,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
218
223
|
requirements:
|
|
219
224
|
- - ">="
|
|
220
225
|
- !ruby/object:Gem::Version
|
|
221
|
-
version:
|
|
226
|
+
version: 1.9.3
|
|
222
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
228
|
requirements:
|
|
224
229
|
- - ">="
|