yt-core 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/docs/_layouts/default.html +5 -0
- data/docs/channels.html +8 -0
- data/docs/groups.html +52 -0
- data/lib/yt/channel.rb +8 -0
- data/lib/yt/core.rb +1 -0
- data/lib/yt/core/version.rb +1 -1
- data/lib/yt/group.rb +32 -0
- data/lib/yt/resource.rb +5 -1
- data/lib/yt/response.rb +3 -2
- data/yt-core.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ecd986ee6a7ae04f3d23ae8a9bd91eb4739e059
|
4
|
+
data.tar.gz: a0ea45421a464e5707c0a75e712764b44b39b91e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2115a2bf9c7517768e1bf1bfc44c21c37e6167cc5672240a6b7a5411e0bd28e9809d6a4fafadc2e8e7568d0792d44e33010ded0a24c88f5fe2c17b88464445cb
|
7
|
+
data.tar.gz: ff578ed38057d5873d68c97b2dedbb4223e929a9f4da1f8a5c5f83a349b4eb16edde57c22add762b77cf3e227cd7f11e53f9bdcba04ea136db66d4c552508e10
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,15 @@ 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.1.7 - 2017-08-27
|
10
|
+
|
11
|
+
* [FEATURE] Add `Channel#groups` and `Yt::Group`
|
12
|
+
* [ENHANCEMENT] Call `Yt#Auth.access_token_was_refreshed` after refreshing a token.
|
13
|
+
|
14
|
+
## 0.1.6 - 2017-08-26
|
15
|
+
|
16
|
+
* [ENHANCEMENT] Compatibility with yt-auth 0.3.0.
|
17
|
+
|
9
18
|
## 0.1.5 - 2017-08-24
|
10
19
|
|
11
20
|
* [FEATURE] Add `Yt::PlaylistItem.insert` and `Yt::PlaylistItem#delete`
|
data/docs/_layouts/default.html
CHANGED
@@ -38,6 +38,11 @@
|
|
38
38
|
{% else %}
|
39
39
|
<li><a href="{{ site.baseurl }}/comments.html">Comments</a></li>
|
40
40
|
{% endif %}
|
41
|
+
{% if page.url == '/groups.html' %}
|
42
|
+
<li><a href="{{ site.baseurl }}/groups.html" class="active">Groups</a></li>
|
43
|
+
{% else %}
|
44
|
+
<li><a href="{{ site.baseurl }}/groups.html">Groups</a></li>
|
45
|
+
{% endif %}
|
41
46
|
{% if page.url == '/errors.html' %}
|
42
47
|
<li><a href="{{ site.baseurl }}/errors.html" class="active">Errors</a></li>
|
43
48
|
{% else %}
|
data/docs/channels.html
CHANGED
@@ -171,3 +171,11 @@ channel = Yt::Channel.mine
|
|
171
171
|
{% include example.html result='#<Yt::Channel @id=UCwCnUcLcb9-eSrHa_RQGkQQ>' %}</pre>
|
172
172
|
</div></dd>
|
173
173
|
</dl>
|
174
|
+
|
175
|
+
<dl>
|
176
|
+
{% include dt.html title="Channel’s analytics groups" label="warning" auth="must authenticate as the channel’s account" %}
|
177
|
+
<dd><a class="anchor" id="groups"></a><div class="highlight"><pre>
|
178
|
+
{% include doc.html instance="Channel#groups" %}{% include example.html object='<span class="no">Yt</span><span class="o">::</span><span class="no">Channel</span>' method='mine.groups' %}
|
179
|
+
{% include example.html result='#<Yt::Relation [#<Yt::Group @id=ABVSo3DwAAA>, ...]>' %}</pre>
|
180
|
+
</div></dd>
|
181
|
+
</dl>
|
data/docs/groups.html
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
title: "Yt::Group"
|
3
|
+
h2: "Groups"
|
4
|
+
---
|
5
|
+
|
6
|
+
<p>
|
7
|
+
<code>Yt::Group</code> represents a <a href="https://developers.google.com/youtube/analytics/v1/reference/groups">YouTube Analytics group</a>.
|
8
|
+
Initialize using its YouTube ID:
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<dl>
|
12
|
+
<dd><a class="anchor" id="new"></a><div class="highlight"><pre>
|
13
|
+
{% include doc.html instance="Group#initialize" %}{% include example.html object='group = <span class="no">Yt</span><span class="o">::</span><span class="no">Group</span>' method='new' params=' <span class="ss">id:</span> <span class="s1">"ABVSo3DwAAA"</span>' %}
|
14
|
+
{% include example.html result='#<Yt::Group @id=ABVSo3DwAAA>' %}
|
15
|
+
{% include doc.html instance="Group#canonical_url" %}{% include example.html object='group' method='title' %}
|
16
|
+
{% include example.html result='"Video group"' %}</pre>
|
17
|
+
</div></dd>
|
18
|
+
</dl>
|
19
|
+
|
20
|
+
<hr />
|
21
|
+
<h4>Authentication</h4>
|
22
|
+
|
23
|
+
<p>
|
24
|
+
All methods of <code>Yt::Group</code> <strong>act on behalf of YouTube accounts</strong> (e.g.: to fetch a group).<br />
|
25
|
+
To use these methods (marked with <span class="label label-warning"> </span> below), you need to <a href="{{ site.baseurl }}/#api_client">get an API Client ID/Secret from Google</a>, then <a href="{{ site.baseurl }}/#tokens">obtain a refresh token</a> from the account you want to act as, and finally configure the values:
|
26
|
+
</p>
|
27
|
+
|
28
|
+
{% highlight ruby %}
|
29
|
+
Yt.configuration.client_id = "<your ID>" ## replace with your client ID
|
30
|
+
Yt.configuration.client_secret = "<your secret>" ## replace with your client secret
|
31
|
+
Yt.configuration.refresh_token = "<token>" ## use the account’s refresh token
|
32
|
+
|
33
|
+
Yt::Group.new(id: 'ABVSo3DwAAA').title
|
34
|
+
# => "Video group"
|
35
|
+
{% endhighlight %}
|
36
|
+
|
37
|
+
<hr />
|
38
|
+
<h4>List of <code>Yt::Group</code> data methods</h4>
|
39
|
+
<dl>
|
40
|
+
{% include dt.html title="Group’s snippet" label="warning" auth="must authenticate as the channel’s account" %}
|
41
|
+
<dd><a class="anchor" id="snippet"></a><div class="highlight"><pre>
|
42
|
+
{% include doc.html instance="Group#id" %}{% include example.html object='group' method='id' result='"ABVSo3DwAAA"' %}
|
43
|
+
{% include doc.html instance="Group#title" %}{% include example.html object='group' method='title' result='"Video Group"' %}
|
44
|
+
{% include doc.html instance="Group#published_at" %}{% include example.html object='group' method='published_at' result='2014-05-02 20:12:57 UTC' %}</pre>
|
45
|
+
</div></dd>
|
46
|
+
|
47
|
+
{% include dt.html title="Group’s content details" label="warning" auth="must authenticate as the group’s account" %}
|
48
|
+
<dd><a class="anchor" id="content_details"></a><div class="highlight"><pre>
|
49
|
+
{% include doc.html instance="Group#item_count" %}{% include example.html object='group' method='item_count' result='4' %}
|
50
|
+
{% include doc.html instance="Group#item_type" %}{% include example.html object='group' method='item_type' result='"youtube#video"' %}</pre>
|
51
|
+
</div></dd>
|
52
|
+
</dl>
|
data/lib/yt/channel.rb
CHANGED
@@ -132,6 +132,14 @@ module Yt
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
# @return [Yt::Relation<Yt::Group>] the analytics groups of the channel.
|
136
|
+
# @see https://developers.google.com/youtube/analytics/v1/reference/groups
|
137
|
+
def groups
|
138
|
+
@groups ||= Relation.new(Group) do |options|
|
139
|
+
get '/youtube/analytics/v1/groups', mine: true
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
135
143
|
# @return [Yt::Relation<Yt::Playlist>] the public playlists of the channel.
|
136
144
|
def playlists
|
137
145
|
@playlists ||= Relation.new(Playlist, channel_id: id) do |options|
|
data/lib/yt/core.rb
CHANGED
data/lib/yt/core/version.rb
CHANGED
data/lib/yt/group.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Yt
|
2
|
+
# Provides methods to interact with YouTube Analytics groups.
|
3
|
+
# @see https://developers.google.com/youtube/analytics/v1/reference/groups
|
4
|
+
class Group < Resource
|
5
|
+
# @!attribute [r] title
|
6
|
+
# @return [String] the group’s title.
|
7
|
+
has_attribute :title, in: :snippet
|
8
|
+
|
9
|
+
# @!attribute [r] published_at
|
10
|
+
# @return [Time] the date and time that the group was created.
|
11
|
+
has_attribute :published_at, in: :snippet, type: Time
|
12
|
+
|
13
|
+
# @!attribute [r] item_count
|
14
|
+
# @return [Integer] the number of items in the group.
|
15
|
+
has_attribute :item_count, in: :content_details, type: Integer
|
16
|
+
|
17
|
+
# @!attribute [r] item_type
|
18
|
+
# @return [String] the type of items in the group.
|
19
|
+
has_attribute :item_type, in: :content_details
|
20
|
+
|
21
|
+
def initialize(data = {})
|
22
|
+
super
|
23
|
+
@selected_data_parts = %i(id snippet content_details)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def part_params
|
29
|
+
super.merge api: 'youtube/analytics/v1'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/yt/resource.rb
CHANGED
@@ -61,7 +61,7 @@ module Yt
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def get_part(required_part)
|
64
|
-
resources = Relation.new(self.class,
|
64
|
+
resources = Relation.new(self.class, part_params) do |options|
|
65
65
|
get resources_path, resource_params(options)
|
66
66
|
end
|
67
67
|
|
@@ -74,6 +74,10 @@ module Yt
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
def part_params
|
78
|
+
{ids: [id]}
|
79
|
+
end
|
80
|
+
|
77
81
|
def type_cast(value, type)
|
78
82
|
case [type]
|
79
83
|
when [Time]
|
data/lib/yt/response.rb
CHANGED
@@ -50,14 +50,15 @@ module Yt
|
|
50
50
|
|
51
51
|
def refresh_access_token
|
52
52
|
if Yt.configuration.refresh_token
|
53
|
-
auth = Auth.
|
53
|
+
auth = Auth.find_by refresh_token: Yt.configuration.refresh_token
|
54
|
+
auth.access_token_was_refreshed
|
54
55
|
Yt.configuration.access_token = auth.access_token
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
58
59
|
def resources_path
|
59
60
|
@options[:item_class].name.split('::').last.gsub(/^(\w{1})(.*)/) do
|
60
|
-
"
|
61
|
+
"/#{@options.fetch(:api, 'youtube/v3')}/#{$1.downcase}#{$2}s"
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
data/yt-core.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
-
spec.add_dependency 'yt-auth', '>= 0.
|
26
|
+
spec.add_dependency 'yt-auth', '>= 0.3.1'
|
27
27
|
spec.add_dependency 'yt-support', '>= 0.1.3'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yt-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yt-auth
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.3.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.3.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yt-support
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- docs/fonts/SecondaRound-Regular.ttf
|
179
179
|
- docs/fonts/SecondaRound-Regular.woff
|
180
180
|
- docs/fonts/SecondaRound-Regular.woff2
|
181
|
+
- docs/groups.html
|
181
182
|
- docs/images/console-01.png
|
182
183
|
- docs/images/console-02.png
|
183
184
|
- docs/images/console-03.png
|
@@ -198,6 +199,7 @@ files:
|
|
198
199
|
- lib/yt/comment_thread.rb
|
199
200
|
- lib/yt/core.rb
|
200
201
|
- lib/yt/core/version.rb
|
202
|
+
- lib/yt/group.rb
|
201
203
|
- lib/yt/no_items_error.rb
|
202
204
|
- lib/yt/playlist.rb
|
203
205
|
- lib/yt/playlist_item.rb
|