youku_client 0.0.3 → 0.0.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: b2b3c6ff2e5c35ce8ec60868f4d3849e83193af1
4
- data.tar.gz: 4f2d155d9876b8bad565b4d444f8f065acb7712d
3
+ metadata.gz: 69e0de5044e79c80e598fc26186171c5f8d913fd
4
+ data.tar.gz: 744c064639ccfba94c204cd0c8ae9ed407868f06
5
5
  SHA512:
6
- metadata.gz: 0435e878d155a98fb87352e0336b8c251cab8aacd5c5d32b36f744e9d12d1f5258fb0d25ec5cf8d53dee63bf9e2da7ee55c330aa9766aa4f454478c018456921
7
- data.tar.gz: 681c598ba6d0cb3e6713391a2f4fec3cd46053bc20c9660f52d7f96dd385f690a54b8d5cd128a7de3457df65f44520660865c6eb0d0b3f389220d797220897c8
6
+ metadata.gz: 67b36cef42ed7e3e56fa531ffa1c887dc70a8f29a03c73deb6919ef15db43fae9ec0053e68d8019d0218401912956164f6284281b68d87d9dceed291752bc852
7
+ data.tar.gz: 075c204230e67681691ea131cba3389596d565c6776e94b0aacec84cb12e33a7a2693e927a4b966592463b8d87a759426f150b8fe77dc935d7c924ad84285d6e
@@ -1,3 +1,8 @@
1
+ 0.0.4
2
+ ----------
3
+ * [Implemented schemas.video.category](https://github.com/Shuttlerock/youku_client/pull/8) ([@BenjaminSchaaf](https://github.com/BenjaminSchaaf))
4
+ * [Implemented searches.video.by_tag](https://github.com/Shuttlerock/youku_client/pull/9) ([@BenjaminSchaaf](https://github.com/BenjaminSchaaf))
5
+
1
6
  0.0.3
2
7
  ------
3
8
  * [Completed non-authenticated portion of the comments API](https://github.com/Shuttlerock/youku_client/pull/7) ([@BenjaminSchaaf](https://github.com/BenjaminSchaaf))
data/README.md CHANGED
@@ -1,49 +1,57 @@
1
1
  # Youku Ruby Gem
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/Shuttlerock/youku_client.png)](http://travis-ci.org/Shuttlerock/youku_client) [![Code Climate](https://codeclimate.com/github/Shuttlerock/youku_client/badges/gpa.svg)](https://codeclimate.com/github/Shuttlerock/youku_client)
3
+ [![Build Status](https://secure.travis-ci.org/Shuttlerock/youku_client.png)](http://travis-ci.org/Shuttlerock/youku_client)
4
+ [![Code Climate](https://codeclimate.com/github/Shuttlerock/youku_client/badges/gpa.svg)](https://codeclimate.com/github/Shuttlerock/youku_client)
4
5
 
5
6
  This is the unofficial Ruby wrapper for the Youku v2 API. It supports not all
6
- endpoints currently available on the
7
- [Youku API](http://open.youku.com/docs?id=0).
7
+ endpoints currently available on the [Youku API](http://open.youku.com/docs?id=0).
8
8
 
9
9
  ## Installation
10
10
 
11
- gem install youku_client
11
+ ``` bash
12
+ gem install youku_client
13
+ ```
12
14
 
13
15
  ### Some quick examples
14
16
 
15
17
  First, instantiate the Client class:
16
18
 
17
- >> client = Youku.new(client_id: 'id', client_secret: 'secret')
19
+ ``` ruby
20
+ >> client = Youku.new(client_id: 'id', client_secret: 'secret')
21
+ ```
18
22
 
19
23
  Get users by IDs:
20
24
 
21
- >> client.users.show_batch(user_ids: '1,2')
25
+ ``` ruby
26
+ >> client.users.show_batch(user_ids: '1,2')
27
+ ```
22
28
 
23
29
  Implemented API endpoints:
24
30
 
25
- - `comments.by_video`
26
- - `comments.hot.by_video`
27
- - `comments.show_batch`
28
- - `comments.show`
29
- - `searches.video.by_keyword`
30
- - `users.friendship.followers`
31
- - `users.friendship.followings`
32
- - `users.show_batch`
33
- - `users.show`
34
- - `videos.by_category`
35
- - `videos.by_related`
36
- - `videos.by_user`
37
- - `videos.favorite.by_user`
38
- - `videos.show_basic_batch`
39
- - `videos.show_basic`
40
- - `videos.show_batch`
41
- - `videos.show`
31
+ - `comments.by_video`
32
+ - `comments.show`
33
+ - `comments.show_batch`
34
+ - `comments.hot.by_video`
35
+ - `searches.video.by_keyword`
36
+ - `searches.video.by_tag`
37
+ - `users.show_batch`
38
+ - `users.show`
39
+ - `users.friendship.followers`
40
+ - `users.friendship.followings`
41
+ - `videos.show_basic`
42
+ - `videos.show_basic_batch`
43
+ - `videos.show`
44
+ - `videos.show_batch`
45
+ - `videos.by_user`
46
+ - `videos.by_related`
47
+ - `videos.by_category`
48
+ - `videos.favorite.by_user`
49
+ - `schemas.video.category`
42
50
 
43
51
  ### Contributions and Pull Requests
44
52
 
45
- No request is too small and I encourage everyone to get involved. So
46
- please if you would like to contribute, let me know and throw me a pull request!
53
+ No request is too small and I encourage everyone to get involved. So please if
54
+ you would like to contribute, let me know and throw me a pull request!
47
55
 
48
56
  ### Requirements
49
57
 
@@ -40,6 +40,13 @@ module Youku
40
40
  def comments
41
41
  Youku::V2::Comments.new(self)
42
42
  end
43
+
44
+ # Public: Get users API.
45
+ #
46
+ # Returns the instance of Youku::V2::Users.
47
+ def schemas
48
+ Youku::V2::Schemas.new(self)
49
+ end
43
50
  end
44
51
  end
45
52
 
@@ -48,3 +55,4 @@ require 'youku/v2/searches'
48
55
  require 'youku/v2/users'
49
56
  require 'youku/v2/videos'
50
57
  require 'youku/v2/comments'
58
+ require 'youku/v2/schemas'
@@ -11,7 +11,7 @@ module Youku
11
11
  #
12
12
  # url - The String url.
13
13
  # params - The Hash query params.
14
- def initialize(url, params)
14
+ def initialize(url, params = {})
15
15
  @url = url
16
16
  @params = params
17
17
  @response = Typhoeus::Request.new(url, params: params, connecttimeout: 5, timeout: 10).run
@@ -0,0 +1,27 @@
1
+ module Youku
2
+ module V2
3
+ class Schemas < Base
4
+ BASE_URI = "#{BASE_URI}/schemas"
5
+
6
+ # Public: Get video API.
7
+ #
8
+ # Returns the instance of Youku::V2::Schemas::Video.
9
+ def video
10
+ Video.new(client)
11
+ end
12
+
13
+ class Video < Base
14
+ BASE_URI = "#{BASE_URI}/video"
15
+
16
+ # Public: Get video categories.
17
+ #
18
+ # See: http://open.youku.com/docs?id=90
19
+ #
20
+ # Returns the instance of Youku::V2::Request.
21
+ def category()
22
+ Youku::V2::Request.new "#{BASE_URI}/category.json"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -12,6 +12,32 @@ module Youku
12
12
  class Video < Base
13
13
  BASE_URI = "#{BASE_URI}/searches/video"
14
14
 
15
+ # Public: Get videos by tag.
16
+ #
17
+ # See: http://open.youku.com/docs?id=80
18
+ #
19
+ # tag - The comma separated String of tags.
20
+ # category - The String category.
21
+ # period - The String period.
22
+ # orderby - The String order of videos.
23
+ # userid - The String or Integer of a youku user ID.
24
+ # page - The Integer page number.
25
+ # count - The Integer page size.
26
+ #
27
+ # Returns the instance of Youku::V2::Request.
28
+ def by_tag(tag: nil, category: nil, userid: nil, period: 'today', orderby: 'relevance', page: 1, count: 20)
29
+ Youku::V2::Request.new "#{BASE_URI}/by_tag.json", {
30
+ client_id: client.client_id,
31
+ tag: tag,
32
+ category: category,
33
+ period: period,
34
+ orderby: orderby,
35
+ userid: userid,
36
+ page: page,
37
+ count: count,
38
+ }
39
+ end
40
+
15
41
  # Public: Get videos by keyword.
16
42
  #
17
43
  # See: http://open.youku.com/docs?id=81
@@ -1,5 +1,5 @@
1
1
  module Youku
2
2
 
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
 
5
5
  end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Youku::V2::Schemas do
4
+
5
+ let(:client) { Youku::Client.new(client_id: 'client-id') }
6
+
7
+ describe '#video' do
8
+ subject { client.schemas.video }
9
+
10
+ it { expect(subject).to be_a Youku::V2::Schemas::Video }
11
+ it { expect(subject.client).to eq client }
12
+ end
13
+
14
+ describe '::Video' do
15
+ describe '#category' do
16
+ let(:url) { 'https://openapi.youku.com/v2/schemas/video/category.json' }
17
+ let(:query) { {} }
18
+
19
+ before do
20
+ stub_request(:get, url).with(query: query).to_return(status: 200)
21
+ end
22
+
23
+ subject { client.schemas.video.category }
24
+
25
+ it_should_behave_like 'a base Youku API V2 requests'
26
+ end
27
+ end
28
+ end
@@ -34,6 +34,28 @@ describe Youku::V2::Searches do
34
34
 
35
35
  it_should_behave_like 'a base Youku API V2 requests'
36
36
  end
37
+
38
+ describe '#by_tag' do
39
+ let(:url) { 'https://openapi.youku.com/v2/searches/video/by_tag.json' }
40
+ let(:query) { {
41
+ client_id: client.client_id,
42
+ tag: 2014,
43
+ category: '',
44
+ period: 'today',
45
+ orderby: 'relevance',
46
+ userid: '',
47
+ page: 1,
48
+ count: 20
49
+ } }
50
+
51
+ before do
52
+ stub_request(:get, url).with(query: query).to_return(status: 200)
53
+ end
54
+
55
+ subject { video.by_tag(tag: 2014) }
56
+
57
+ it_should_behave_like 'a base Youku API V2 requests'
58
+ end
37
59
  end
38
60
 
39
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youku_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Vokhmin
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-01 00:00:00.000000000 Z
13
+ date: 2015-12-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: typhoeus
@@ -116,6 +116,7 @@ files:
116
116
  - lib/youku/v2/base.rb
117
117
  - lib/youku/v2/comments.rb
118
118
  - lib/youku/v2/request.rb
119
+ - lib/youku/v2/schemas.rb
119
120
  - lib/youku/v2/searches.rb
120
121
  - lib/youku/v2/users.rb
121
122
  - lib/youku/v2/videos.rb
@@ -125,6 +126,7 @@ files:
125
126
  - spec/support/shared_examples/youku_api_v2_examples.rb
126
127
  - spec/youku/client_spec.rb
127
128
  - spec/youku/v2/comments_spec.rb
129
+ - spec/youku/v2/schemas_spec.rb
128
130
  - spec/youku/v2/searches_spec.rb
129
131
  - spec/youku/v2/users_spec.rb
130
132
  - spec/youku/v2/videos_spec.rb
@@ -158,6 +160,7 @@ test_files:
158
160
  - spec/support/shared_examples/youku_api_v2_examples.rb
159
161
  - spec/youku/client_spec.rb
160
162
  - spec/youku/v2/comments_spec.rb
163
+ - spec/youku/v2/schemas_spec.rb
161
164
  - spec/youku/v2/searches_spec.rb
162
165
  - spec/youku/v2/users_spec.rb
163
166
  - spec/youku/v2/videos_spec.rb