yt 0.10.3 → 0.10.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed082f94cdaa3fa496bd9ef6cffd95754fb292c1
4
- data.tar.gz: 38a76b4cca68dcea1c70ab1bfe1423e6502a9922
3
+ metadata.gz: 83e093f9574237e7acfe751a152ebe9f2b700cd5
4
+ data.tar.gz: f136bf0de7f233e096444e5a7b3c51e5efa37d14
5
5
  SHA512:
6
- metadata.gz: c28709d46e78e6ed3b0b20d1c72d106b5330477e70088bd21193547963113b97594f44258c597a7b9203ba00e26defb838a748fb14bd958c59ea095fceb192f5
7
- data.tar.gz: 535292f6eb80998cb0b46e6032eff963e7a0bae948b260d2be881c910f0e4eb5e664b72eff631155d6a1970e0e67c3210a3f5d9aa0053cb8d1d5094bda3c0680
6
+ metadata.gz: 409c0e3eb775a2a4d06b99a5f76edefb006d7430d8cfa0722cf4774e0a44db2a912c82b44a3f6f7b2a0c58a3df85a713fd725b8b6f41a767cc2390c24c9d47d4
7
+ data.tar.gz: 4b7ed9f82d43e2f4bcd536c9e1d3bdc0e67a7bfb5e3eadab8b0ecd4bb144c2812c0e6c829482dfad0b48cba298debb4041ad96c6c199f830c6cb2e3ff77b4189
@@ -6,6 +6,10 @@ 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.10.4 - 2014-08-15
10
+
11
+ * [BUGFIX] List tags of videos retrieved with channel.videos and account.videos
12
+
9
13
  ## 0.10.3 - 2014-08-12
10
14
 
11
15
  * [FEATURE] Add methods to insert and delete ContentID references
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yt (0.10.3)
4
+ yt (0.10.4)
5
5
  activesupport
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -41,7 +41,7 @@ To install on your system, run
41
41
 
42
42
  To use inside a bundled Ruby project, add this line to the Gemfile:
43
43
 
44
- gem 'yt', '~> 0.10.3'
44
+ gem 'yt', '~> 0.10.4'
45
45
 
46
46
  Since the gem follows [Semantic Versioning](http://semver.org),
47
47
  indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
@@ -13,9 +13,14 @@ module Yt
13
13
 
14
14
  # @return [Yt::Models::Video] a new video initialized with one of
15
15
  # the items returned by asking YouTube for a list of videos.
16
+ # According to the documentation, tags are only visible to the video's
17
+ # uploader, and are not returned when search for all the videos of an
18
+ # account. Instead, a separate call to Videos#list is required. Setting
19
+ # +includes_tags+ to +false+ makes sure that `video.tags` will do this.
16
20
  # @see https://developers.google.com/youtube/v3/docs/videos#resource
17
21
  def new_item(data)
18
- Yt::Video.new id: data['id']['videoId'], snippet: data['snippet'], auth: @auth
22
+ snippet = data.fetch('snippet', {}).merge includes_tags: false
23
+ Yt::Video.new id: data['id']['videoId'], snippet: snippet, auth: @auth
19
24
  end
20
25
 
21
26
  # @return [Hash] the parameters to submit to YouTube to list videos.
@@ -162,6 +162,18 @@ module Yt
162
162
  def video
163
163
  @video ||= Video.new id: video_id, auth: @auth if video_id
164
164
  end
165
+
166
+ # Returns whether YouTube API includes tags in this snippet.
167
+ # YouTube API only returns tags on Videos#list, not on Videos#search.
168
+ # This method is used to guarantee that, when a video was instantiated
169
+ # by calling account.videos or channel.videos, then video.tags is not
170
+ # simply returned as empty, but an additional call to Videos#list is
171
+ # made to retrieve the correct tags.
172
+ # @see https://developers.google.com/youtube/v3/docs/videos
173
+ # @return [Boolean] whether YouTube API includes tags in this snippet.
174
+ def includes_tags
175
+ @includes_tags ||= @data.fetch :includes_tags, true
176
+ end
165
177
  end
166
178
  end
167
179
  end
@@ -5,7 +5,7 @@ module Yt
5
5
  # Provides methods to interact with YouTube videos.
6
6
  # @see https://developers.google.com/youtube/v3/docs/videos
7
7
  class Video < Resource
8
- delegate :tags, :channel_id, :channel_title, :category_id,
8
+ delegate :channel_id, :channel_title, :category_id,
9
9
  :live_broadcast_content, to: :snippet
10
10
 
11
11
  delegate :deleted?, :failed?, :processed?, :rejected?, :uploaded?,
@@ -67,6 +67,19 @@ module Yt
67
67
  delegate :view_count, :like_count, :dislike_count, :favorite_count,
68
68
  :comment_count, to: :statistics_set
69
69
 
70
+ # Returns the list of keyword tags associated with the video.
71
+ # Since YouTube API only returns tags on Videos#list, the memoized
72
+ # @snippet is erased if the video was instantiated through Video#search
73
+ # (e.g., by calling account.videos or channel.videos), so that the full
74
+ # snippet (with tags) is loaded, rather than the partial one.
75
+ # @see https://developers.google.com/youtube/v3/docs/videos
76
+ # @return [Array<Yt::Models::Tag>] the list of keyword tags associated
77
+ # with the video.
78
+ def tags
79
+ @snippet = nil unless snippet.includes_tags
80
+ snippet.tags
81
+ end
82
+
70
83
  # Deletes the video.
71
84
  #
72
85
  # This method requires {Resource#auth auth} to return an authenticated
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.10.3'
2
+ VERSION = '0.10.4'
3
3
  end
@@ -11,8 +11,12 @@ describe Yt::Account, :device_app do
11
11
  end
12
12
 
13
13
  describe '.videos' do
14
- it { expect($account.videos).to be_a Yt::Collections::Videos }
15
- it { expect($account.videos.where(order: 'viewCount').first).to be_a Yt::Video }
14
+ let(:video) { $account.videos.where(order: 'viewCount').first }
15
+
16
+ specify 'returns the account’s videos with its tags' do
17
+ expect(video).to be_a Yt::Video
18
+ expect(video.tags).not_to be_empty
19
+ end
16
20
 
17
21
  describe '.where(q: query_string)' do
18
22
  let(:count) { $account.videos.where(q: query).count }
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.10.3
4
+ version: 0.10.4
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-08-12 00:00:00.000000000 Z
11
+ date: 2014-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport