yt-core 0.1.2 → 0.1.3
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 +0 -1
- data/.travis.yml +0 -2
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/docs/_layouts/default.html +5 -0
- data/docs/channels.html +3 -1
- data/docs/comments.html +57 -0
- data/docs/videos.html +36 -0
- data/lib/yt/channel.rb +10 -0
- data/lib/yt/comment.rb +27 -0
- data/lib/yt/comment_thread.rb +19 -0
- data/lib/yt/core.rb +3 -0
- data/lib/yt/core/version.rb +1 -1
- data/lib/yt/resource.rb +2 -0
- data/lib/yt/response.rb +4 -0
- data/lib/yt/video.rb +7 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 368c82a9dfd70ec0b355a4d1789e30ea9092c178
|
4
|
+
data.tar.gz: 274884baeadb9e15cc58acf719bee6712a24bec4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc56f8e8ecac5151fedf2082584cf02e6eaee572adbe461801a5a2372c4ea84dd3250300bbf392dce0101eb654f18fb522771325e0bd10e3df7af4d5fef8e791
|
7
|
+
data.tar.gz: 5f56a363ea52f728a7a1ca0f5f0a568f793961f918f712fe23e049c9075981858a49232ad8ed0563ac4a00e0beb544844597511d029bd9aa05518cfa63bb1a41
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,11 @@ 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.3 - 2017-05-23
|
10
|
+
|
11
|
+
* [FEATURE] Add Comment and CommentThread
|
12
|
+
* [FEATURE] Add Channel#featured_channels_title and Channel#featured_channels_urls
|
13
|
+
|
9
14
|
## 0.1.2 - 2017-04-06
|
10
15
|
|
11
16
|
* [BUGFIX] Fix cases like `channel.select(:snippet).view_count` where attribute does not belong to any selected part.
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ The **source code** is available on [GitHub](https://github.com/fullscreen/yt-co
|
|
10
10
|
[](https://gemnasium.com/Fullscreen/yt-core)
|
11
11
|
[](https://codeclimate.com/github/Fullscreen/yt-core)
|
12
12
|
[](http://www.rubydoc.info/gems/yt-core/frames)
|
13
|
-
[](http://rubygems.org/gems/yt-core)
|
13
|
+
[](http://rubygems.org/gems/yt-core)
|
14
14
|
|
15
15
|
After [registering your app](https://fullscreen.github.io/yt-core/), you can run commands like:
|
16
16
|
|
data/docs/_layouts/default.html
CHANGED
@@ -33,6 +33,11 @@
|
|
33
33
|
{% else %}
|
34
34
|
<li><a href="{{ site.baseurl }}/playlist_items.html">Playlist Items</a></li>
|
35
35
|
{% endif %}
|
36
|
+
{% if page.url == '/comments.html' %}
|
37
|
+
<li><a href="{{ site.baseurl }}/comments.html" class="active">Comments</a></li>
|
38
|
+
{% else %}
|
39
|
+
<li><a href="{{ site.baseurl }}/comments.html">Comments</a></li>
|
40
|
+
{% endif %}
|
36
41
|
{% if page.url == '/errors.html' %}
|
37
42
|
<li><a href="{{ site.baseurl }}/errors.html" class="active">Errors</a></li>
|
38
43
|
{% else %}
|
data/docs/channels.html
CHANGED
@@ -66,7 +66,9 @@ channel.title # => "Yt Test"
|
|
66
66
|
<dd><a class="anchor" id="branding_settings"></a><div class="highlight"><pre>
|
67
67
|
{% include doc.html instance="Channel#banner_image_url" %}{% include example.html object='channel' method='banner_image_url' result='"https://yt3.ggpht.com/9dh4rj-k-no"' %}
|
68
68
|
{% include doc.html instance="Channel#keywords" %}{% include example.html object='channel' method='keywords' result='["Some", "tag"]' %}
|
69
|
-
{% include doc.html instance="Channel#unsubscribed_trailer" %}{% include example.html object='channel' method='unsubscribed_trailer' result='"gknzFj_0vvY"' %}
|
69
|
+
{% include doc.html instance="Channel#unsubscribed_trailer" %}{% include example.html object='channel' method='unsubscribed_trailer' result='"gknzFj_0vvY"' %}
|
70
|
+
{% include doc.html instance="Channel#featured_channels_title" %}{% include example.html object='channel' method='featured_channels_title' result='"Featured channels"' %}
|
71
|
+
{% include doc.html instance="Channel#featured_channels_urls" %}{% include example.html object='channel' method='featured_channels_urls' result='["UCxO1tY8h1AhOz0T4ENwmpow"]' %}</pre>
|
70
72
|
</div></dd>
|
71
73
|
</dl>
|
72
74
|
<p>
|
data/docs/comments.html
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
title: "Yt::CommentThread and Yt::Comment"
|
3
|
+
h2: "Comments"
|
4
|
+
---
|
5
|
+
|
6
|
+
<p>
|
7
|
+
<code>Yt::CommentThread</code> represents a <a href="https://developers.google.com/youtube/v3/docs/commentThread">YouTube comment thread</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="CommentThread#initialize" %}{% include example.html object='thread = <span class="no">Yt</span><span class="o">::</span><span class="no">CommentThread</span>' method='new' params=' <span class="ss">id:</span> <span class="s1">"z121srzx5oqiyrbce23nevcwrpqfenix004"</span>' %}
|
14
|
+
{% include example.html result='#<Yt::CommentThread @id=z121srzx5oqiyrbce23nevcwrpqfenix004>' %}
|
15
|
+
{% include doc.html instance="CommentThread#canonical_url" %}{% include example.html object='thread' method='top_level_comment.text_display' %}
|
16
|
+
{% include example.html result='"A public comment"' %}</pre>
|
17
|
+
</div></dd>
|
18
|
+
</dl>
|
19
|
+
|
20
|
+
<hr />
|
21
|
+
<h4>Authentication</h4>
|
22
|
+
|
23
|
+
<p>
|
24
|
+
Most methods of <code>Yt::CommentThread</code> <strong>retrieve public data</strong> from YouTube (e.g.: the top level comment).<br />
|
25
|
+
To use these methods (marked with <span class="label label-success"> </span> below), you only need to <a href="{{ site.baseurl }}/#api_key">generate an API key</a> and configure:
|
26
|
+
</p>
|
27
|
+
|
28
|
+
{% highlight ruby %}
|
29
|
+
Yt.configuration.api_key = "<your api key>" ## use your API key
|
30
|
+
|
31
|
+
thread = Yt::CommentThread.new id: 'z121srzx5oqiyrbce23nevcwrpqfenix004' ## use any ID
|
32
|
+
thread.top_level_comment.text_display # => "A public comment"
|
33
|
+
{% endhighlight %}
|
34
|
+
|
35
|
+
<hr />
|
36
|
+
<h4>List of <code>Yt::CommentThread</code> data methods</h4>
|
37
|
+
<dl>
|
38
|
+
{% include dt.html title="CommentThread’s snippet" label="success" auth="any authentication works" %}
|
39
|
+
<dd><a class="anchor" id="snippet"></a><div class="highlight"><pre>
|
40
|
+
{% include doc.html instance="CommentThread#id" %}{% include example.html object='thread' method='id' result='"z121srzx5oqiyrbce23nevcwrpqfenix004"' %}
|
41
|
+
{% include doc.html instance="CommentThread#channel_id" %}{% include example.html object='thread' method='channel_id' result='nil' %}
|
42
|
+
{% include doc.html instance="CommentThread#video_id" %}{% include example.html object='thread' method='video_id' result='"gknzFj_0vvY"' %}
|
43
|
+
{% include doc.html instance="CommentThread#top_level_comment" %}{% include example.html object='thread' method='top_level_comment' result='<Yt::Comment @id=z121srzx5...>' %}</pre>
|
44
|
+
</div></dd>
|
45
|
+
|
46
|
+
<hr />
|
47
|
+
<h4>List of <code>Yt::Comment</code> data methods</h4>
|
48
|
+
<dl>
|
49
|
+
{% include dt.html title="Comment’s snippet" label="success" auth="any authentication works" %}
|
50
|
+
<dd><a class="anchor" id="snippet"></a><div class="highlight"><pre>
|
51
|
+
{% include doc.html instance="Comment#id" %}{% include example.html object='comment' method='id' result='"z121srzx5oqiyrbce23nevcwrpqfenix004"' %}
|
52
|
+
{% include doc.html instance="Comment#text_display" %}{% include example.html object='comment' method='text_display' result='"A public comment"' %}
|
53
|
+
{% include doc.html instance="Comment#author_display_name" %}{% include example.html object='comment' method='author_display_name' result='"Yt Test"' %}
|
54
|
+
{% include doc.html instance="Comment#author_profile_image_url" %}{% include example.html object='comment' method='author_profile_image_url' result='"https://yt3.ggpht.com/-lC#w"' %}
|
55
|
+
{% include doc.html instance="Comment#author_channel_url" %}{% include example.html object='comment' method='author_channel_url' result='"http://www.youtube.com/channel/UCwCnUcLc..."' %}
|
56
|
+
{% include doc.html instance="Comment#author_channel_id" %}{% include example.html object='comment' method='author_channel_id' result='"UCwCnUcLcb9-eSrHa_RQGkQQ"' %}</pre>
|
57
|
+
</div></dd>
|
data/docs/videos.html
CHANGED
@@ -102,3 +102,39 @@ video.title # => "First public video"
|
|
102
102
|
{% include example.html result='#<Yt::Channel @id=UCwCnUcLcb9-eSrHa_RQGkQQ>' %}</pre>
|
103
103
|
</div></dd>
|
104
104
|
</dl>
|
105
|
+
|
106
|
+
|
107
|
+
<dl>
|
108
|
+
{% include dt.html title="Video’s comment threads" label="success" auth="any authentication works" %}
|
109
|
+
<dd><a class="anchor" id="threads"></a><div class="highlight"><pre>
|
110
|
+
{% include doc.html instance="Video#threads" %}{% include example.html object='video' method='threads' %}
|
111
|
+
{% include example.html result='#<Yt::Relation [#<Yt::Thread @id=z119d45>, #<Yt::Thread @id=z120d734>, ...]>' %}</pre>
|
112
|
+
</div></dd>
|
113
|
+
</dl>
|
114
|
+
<p>
|
115
|
+
Before iterating through threads, use <code>select</code> to specify which <a href="https://developers.google.com/youtube/v3/docs/commentThreads/list#part">parts</a> to load:
|
116
|
+
</p>
|
117
|
+
<dl>
|
118
|
+
<dd><a class="anchor" id="select"></a><div class="highlight"><pre>
|
119
|
+
{% include doc.html instance="Relation#select" %}{% include example.html object='threads = video.threads' method='select' params=' <span class="ss">:id</span>, <span class="ss">:snippet</span>' %}
|
120
|
+
{% include example.html object='threads' method='map <span class="ss">&:id</span>' result='["z119d45", ...]' %}
|
121
|
+
{% include example.html object='threads' method='map <span class="ss">&:top_level_comment</span>' result='[#<Yt::Comment @id=z119d45>, ...]' %}</pre>
|
122
|
+
</div></dd>
|
123
|
+
</dl>
|
124
|
+
<p>
|
125
|
+
You can also use <code>limit</code> to only fetch a certain number of threads:
|
126
|
+
</p>
|
127
|
+
<dl>
|
128
|
+
<dd><a class="anchor" id="limit"></a><div class="highlight"><pre>
|
129
|
+
{% include doc.html instance="Relation#limit" %}{% include example.html object='threads = video.threads' method='limit' params=' <span class="mi">2</span>' %}
|
130
|
+
{% include example.html object='threads' method='map <span class="ss">&:id</span>' result='["z119d45", "z120d734"]' %}</pre>
|
131
|
+
</div></dd>
|
132
|
+
</dl>
|
133
|
+
<p>
|
134
|
+
You can also use <code>size</code> to quickly obtain the estimated number of threads:
|
135
|
+
</p>
|
136
|
+
<dl>
|
137
|
+
<dd><a class="anchor" id="size"></a><div class="highlight"><pre>
|
138
|
+
{% include doc.html instance="Relation#size" %}{% include example.html object='video.threads' method='size' result='63' %}</pre>
|
139
|
+
</div></dd>
|
140
|
+
</dl>
|
data/lib/yt/channel.rb
CHANGED
@@ -81,6 +81,16 @@ module Yt
|
|
81
81
|
# in the channel page’s browse view for unsubscribed viewers.
|
82
82
|
has_attribute :unsubscribed_trailer, in: %i(branding_settings channel)
|
83
83
|
|
84
|
+
# @!attribute [r] featured_channels_title
|
85
|
+
# @return [<String, nil>] the title that displays above the featured
|
86
|
+
# channels module. The title has a maximum length of 30 characters.
|
87
|
+
has_attribute :featured_channels_title, in: %i(branding_settings channel)
|
88
|
+
|
89
|
+
# @!attribute [r] featured_channels_title
|
90
|
+
# @return [Array<String>] the IDs of the channels linked in the featured
|
91
|
+
# channels module.
|
92
|
+
has_attribute :featured_channels_urls, in: %i(branding_settings channel), default: []
|
93
|
+
|
84
94
|
# @return [String] the canonical form of the channel’s URL.
|
85
95
|
def canonical_url
|
86
96
|
"https://www.youtube.com/channel/#{id}"
|
data/lib/yt/comment.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Yt
|
2
|
+
# Provides methods to interact with YouTube comments.
|
3
|
+
# @see https://developers.google.com/youtube/v3/docs/comments
|
4
|
+
class Comment < Resource
|
5
|
+
# @!attribute [r] author_channel_id
|
6
|
+
# @return [String] the comment’s text.
|
7
|
+
has_attribute :text_display, in: :snippet
|
8
|
+
|
9
|
+
# @!attribute [r] author_display_name
|
10
|
+
# @return [String] the display name of the user who posted the comment.
|
11
|
+
has_attribute :author_display_name, in: :snippet
|
12
|
+
|
13
|
+
# @!attribute [r] author_profile_image_url
|
14
|
+
# @return [String] the URL of the avatar of the user who posted the comment.
|
15
|
+
has_attribute :author_profile_image_url, in: :snippet
|
16
|
+
|
17
|
+
# @!attribute [r] author_channel_url
|
18
|
+
# @return [String] the URL of the comment author’s YouTube channel.
|
19
|
+
has_attribute :author_channel_url, in: :snippet
|
20
|
+
|
21
|
+
# @!attribute [r] author_channel_id
|
22
|
+
# @return [String] the ID of the comment author’s YouTube channel.
|
23
|
+
has_attribute :author_channel_id, in: :snippet do |author_channel_id|
|
24
|
+
author_channel_id['value']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Yt
|
2
|
+
# Provides methods to interact with YouTube comment threads.
|
3
|
+
# @see https://developers.google.com/youtube/v3/docs/commentThreads
|
4
|
+
class CommentThread < Resource
|
5
|
+
# @!attribute [r] channel_id
|
6
|
+
# @return [String] the ID of the channel that the comments refer to.
|
7
|
+
# @return [nil] if the comment does not refer to a channel.
|
8
|
+
has_attribute :channel_id, in: :snippet
|
9
|
+
|
10
|
+
# @!attribute [r] video_id
|
11
|
+
# @return [String] the ID of the video that the comments refer to.
|
12
|
+
# @return [nil] if the comment refers to the channel itself.
|
13
|
+
has_attribute :video_id, in: :snippet
|
14
|
+
|
15
|
+
# @!attribute [r] top_level_comment
|
16
|
+
# @return [Comment] the thread's top-level comment.
|
17
|
+
has_attribute :top_level_comment, in: :snippet, type: Comment
|
18
|
+
end
|
19
|
+
end
|
data/lib/yt/core.rb
CHANGED
data/lib/yt/core/version.rb
CHANGED
data/lib/yt/resource.rb
CHANGED
data/lib/yt/response.rb
CHANGED
@@ -40,6 +40,10 @@ module Yt
|
|
40
40
|
default_params(options).merge playlist_id: options[:playlist_id]
|
41
41
|
end
|
42
42
|
|
43
|
+
def video_threads_params(options)
|
44
|
+
default_params(options).merge video_id: options[:video_id]
|
45
|
+
end
|
46
|
+
|
43
47
|
def resource_params(options)
|
44
48
|
default_params(options).merge id: options[:ids].join(',')
|
45
49
|
end
|
data/lib/yt/video.rb
CHANGED
@@ -180,6 +180,13 @@ module Yt
|
|
180
180
|
@channel ||= Channel.new id: channel_id
|
181
181
|
end
|
182
182
|
|
183
|
+
# @return [Yt::Relation<Yt::CommentThread>] the threads of the video.
|
184
|
+
def threads
|
185
|
+
@threads ||= Relation.new(CommentThread, video_id: id) do |options|
|
186
|
+
fetch '/youtube/v3/commentThreads', video_threads_params(options)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
183
190
|
private
|
184
191
|
|
185
192
|
# @return [Integer] the duration of the resource as reported by YouTube.
|
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.3
|
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-
|
11
|
+
date: 2017-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yt-support
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- docs/_layouts/default.html
|
151
151
|
- docs/apple-touch-icon-precomposed.png
|
152
152
|
- docs/channels.html
|
153
|
+
- docs/comments.html
|
153
154
|
- docs/css/yt.css
|
154
155
|
- docs/errors.html
|
155
156
|
- docs/favicon.ico
|
@@ -179,6 +180,8 @@ files:
|
|
179
180
|
- docs/urls.html
|
180
181
|
- docs/videos.html
|
181
182
|
- lib/yt/channel.rb
|
183
|
+
- lib/yt/comment.rb
|
184
|
+
- lib/yt/comment_thread.rb
|
182
185
|
- lib/yt/core.rb
|
183
186
|
- lib/yt/core/version.rb
|
184
187
|
- lib/yt/no_items_error.rb
|