yt 0.11.4 → 0.11.5

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: d4252625265d920e49c56abd24211d37be9881ba
4
- data.tar.gz: 620dceb9f5722aa8108a06dcc5bc665386a3d1ee
3
+ metadata.gz: 42014f27313df641d183c3372c321750d4286503
4
+ data.tar.gz: fdfcb6df1b63ed5943f50292111c43279c3e8cbd
5
5
  SHA512:
6
- metadata.gz: 529db7f3f2bc51ccbabd6a42c320406b87f1320877fe182b04f86d087febc406d65fcd9baa16def7dcfd49997cf6394f149634b26d8dcd9172cf19f71b45363e
7
- data.tar.gz: c6357576d740ca80c940392f6794f739715703a660bdc9a1987ea90a68b8ce7d5ef47013ea63e0d85af5175be69684d88bd28ddb6c90da1bca2a822a197b7868
6
+ metadata.gz: bb5e31dcea230569c121333be4829eb24c964224c88e60ba506fbbe7aadc2aae4019be292a944135da2b07e0fa89d2e36306adcc5f853685d4d0c83612901163
7
+ data.tar.gz: 34df50c4d27f24824605e49e8a9305b8efdbe290b94aab35f31ff5f254f979ed5edac78ec266fdae61ebec4a0333226882e6185ec68443f1206c60db0eb41db2
@@ -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.11.5 - 2014-08-27
10
+
11
+ * [BUGFIX] Make videos.where(id: 'MESycYJytkU').first.id return 'MESycYJytkU'
12
+
9
13
  ## 0.11.4 - 2014-08-27
10
14
 
11
15
  * [ENHANCEMENT] Add Video search even by id, chart or rating
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.11.4'
44
+ gem 'yt', '~> 0.11.5'
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*)
@@ -12,8 +12,9 @@ module Yt
12
12
  private
13
13
 
14
14
  def attributes_for_new_item(data)
15
+ id = use_list_endpoint? ? data['id'] : data['id']['videoId']
15
16
  snippet = data.fetch('snippet', {}).merge includes_tags: false
16
- {id: data['id']['videoId'], snippet: snippet, auth: @auth}
17
+ {id: id, snippet: snippet, auth: @auth}
17
18
  end
18
19
 
19
20
  # @return [Hash] the parameters to submit to YouTube to list videos.
@@ -52,17 +53,20 @@ module Yt
52
53
  end
53
54
  end
54
55
 
56
+ def videos_path
57
+ use_list_endpoint? ? '/youtube/v3/videos' : '/youtube/v3/search'
58
+ end
59
+
55
60
  # @private
61
+ # YouTube API provides two different endpoints to get a list of videos:
62
+ # /videos should be used when the query specifies video IDs or a chart,
63
+ # /search otherwise.
64
+ # @return [Boolean] whether to use the /videos endpoint.
56
65
  # @todo: This is one of two places outside of base.rb where @where_params
57
66
  # is accessed; it should be replaced with a filter on params instead.
58
- # @see https://developers.google.com/youtube/v3/docs/videos/list
59
- def videos_path
67
+ def use_list_endpoint?
60
68
  @where_params ||= {}
61
- if @parent.nil? && (@where_params.keys & [:id, :chart]).any?
62
- '/youtube/v3/videos'
63
- else
64
- '/youtube/v3/search'
65
- end
69
+ @parent.nil? && (@where_params.keys & [:id, :chart]).any?
66
70
  end
67
71
  end
68
72
  end
@@ -76,7 +76,9 @@ module Yt
76
76
  # @return [Array<Yt::Models::Tag>] the list of keyword tags associated
77
77
  # with the video.
78
78
  def tags
79
- @snippet = nil unless snippet.includes_tags
79
+ unless snippet.tags.any? || snippet.includes_tags || @auth.nil?
80
+ @snippet = nil
81
+ end
80
82
  snippet.tags
81
83
  end
82
84
 
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.11.4'
2
+ VERSION = '0.11.5'
3
3
  end
@@ -13,8 +13,12 @@ describe Yt::Collections::Videos, :server_app do
13
13
  expect(videos.where(q: 'Fullscreen CreatorPlatform', video_duration: :long).size).to be < 100_000
14
14
  end
15
15
 
16
- specify 'with a list of video IDs, only returns the videos matching those IDs' do
17
- expect(videos.where(id: 'MESycYJytkU,invalid').size).to be 1
16
+ context 'with a list of video IDs, only returns the videos matching those IDs' do
17
+ let(:video_id) { 'MESycYJytkU' }
18
+ let(:videos_by_id) { videos.where id: "#{video_id},invalid" }
19
+
20
+ it { expect(videos_by_id.size).to be 1 }
21
+ it { expect(videos_by_id.first.id).to eq video_id }
18
22
  end
19
23
 
20
24
  specify 'with a chart parameter, only returns videos of that chart', :ruby2 do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.4
4
+ version: 0.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo