youku_client 0.0.2 → 0.0.3

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: 88241102eb4635e4dd5c689499ffe9059708ee56
4
- data.tar.gz: c934e26daab56f7e827d18b15f72caf13915b429
3
+ metadata.gz: b2b3c6ff2e5c35ce8ec60868f4d3849e83193af1
4
+ data.tar.gz: 4f2d155d9876b8bad565b4d444f8f065acb7712d
5
5
  SHA512:
6
- metadata.gz: 4c0ba3dc6da07a1a17b3d26ddcfa6b01b571433ac4017584ce5dca2129da268d808b873d78844a75c84de644677ea55901a1c95e26b0f58ad8e02f7219bbcde8
7
- data.tar.gz: ad4a0f89d148781291e40f387f9cef780ff7e26fd7928a963dbc5aa2be6144e5ff005ea2a48af6e0d3402fb97e94b4f24a281f8191b585b78539b7b695b6151a
6
+ metadata.gz: 0435e878d155a98fb87352e0336b8c251cab8aacd5c5d32b36f744e9d12d1f5258fb0d25ec5cf8d53dee63bf9e2da7ee55c330aa9766aa4f454478c018456921
7
+ data.tar.gz: 681c598ba6d0cb3e6713391a2f4fec3cd46053bc20c9660f52d7f96dd385f690a54b8d5cd128a7de3457df65f44520660865c6eb0d0b3f389220d797220897c8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.0.3
2
+ ------
3
+ * [Completed non-authenticated portion of the comments API](https://github.com/Shuttlerock/youku_client/pull/7) ([@BenjaminSchaaf](https://github.com/BenjaminSchaaf))
4
+ * [Completed non-authenticated portion of the users API](https://github.com/Shuttlerock/youku_client/pull/6) ([@BenjaminSchaaf](https://github.com/BenjaminSchaaf))
5
+ * [Completed non-authenticated portion of the videos API](https://github.com/Shuttlerock/youku_client/pull/5) ([@BenjaminSchaaf](https://github.com/BenjaminSchaaf))
6
+
1
7
  0.0.2
2
8
  ------
3
9
  * [Fixed generated urls not matching webmocks for `nil` parameters.](https://github.com/Shuttlerock/youku_client/pull/1) ([@BenjaminSchaaf](https://github.com/BenjaminSchaaf))
data/README.md CHANGED
@@ -22,11 +22,23 @@ Get users by IDs:
22
22
 
23
23
  Implemented API endpoints:
24
24
 
25
+ - `comments.by_video`
26
+ - `comments.hot.by_video`
27
+ - `comments.show_batch`
28
+ - `comments.show`
25
29
  - `searches.video.by_keyword`
30
+ - `users.friendship.followers`
31
+ - `users.friendship.followings`
26
32
  - `users.show_batch`
27
- - `videos.video.by_user`
28
- - `videos.video.show_batch`
29
- - `videos.video.show`
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`
30
42
 
31
43
  ### Contributions and Pull Requests
32
44
 
@@ -20,6 +20,63 @@ module Youku
20
20
  count: count,
21
21
  }
22
22
  end
23
+
24
+ # Public: Get a comment by ID.
25
+ #
26
+ # See: http://open.youku.com/docs?id=32
27
+ #
28
+ # comment_id - The string comment ID.
29
+ #
30
+ # Returns the instance of Youku::V2::Request.
31
+ def show(comment_id: nil)
32
+ Youku::V2::Request.new "#{BASE_URI}/show.json", {
33
+ client_id: client.client_id,
34
+ comment_id: comment_id,
35
+ }
36
+ end
37
+
38
+ # Public: Get comments by their IDs.
39
+ #
40
+ # See: http://open.youku.com/docs?id=34
41
+ #
42
+ # comment_ids - The string comment IDs.
43
+ #
44
+ # Returns the instance of Youku::V2::Request.
45
+ def show_batch(comment_ids: nil)
46
+ Youku::V2::Request.new "#{BASE_URI}/show_batch.json", {
47
+ client_id: client.client_id,
48
+ comment_ids: comment_ids,
49
+ }
50
+ end
51
+
52
+ # Public: Get hot API.
53
+ #
54
+ # Returns the instance of Youku::V2::Comments::Hot.
55
+ def hot
56
+ Hot.new(client)
57
+ end
58
+
59
+ class Hot < Base
60
+ BASE_URI = "#{BASE_URI}/hot"
61
+
62
+ # Public: Get hot comments given a video.
63
+ #
64
+ # See: http://open.youku.com/docs?id=36
65
+ #
66
+ # video_id - The string video ID.
67
+ # page - The Integer page number.
68
+ # count - The Integer page size.
69
+ #
70
+ # Returns the instance of Youku::V2::Request.
71
+ def by_video(video_id: nil, page: 1, count: 20)
72
+ Youku::V2::Request.new "#{BASE_URI}/by_video.json", {
73
+ client_id: client.client_id,
74
+ video_id: video_id,
75
+ page: page,
76
+ count: count
77
+ }
78
+ end
79
+ end
23
80
  end
24
81
  end
25
82
  end
@@ -34,6 +34,57 @@ module Youku
34
34
  user_name: user_name,
35
35
  }
36
36
  end
37
+
38
+ # Public: Get favourite API.
39
+ #
40
+ # Returns the instance of Youku::V2::Users::Friendship.
41
+ def friendship
42
+ Friendship.new(client)
43
+ end
44
+
45
+ class Friendship < Base
46
+ BASE_URI = "#{BASE_URI}/friendship"
47
+
48
+ # Public: Get the users following a given user.
49
+ #
50
+ # See: http://open.youku.com/docs?id=26
51
+ #
52
+ # user_id - The String Youku user ID.
53
+ # user_name - The String Youku user name.
54
+ # page - The Integer page number.
55
+ # count - The Integer page size.
56
+ #
57
+ # Returns the instance of Youku::V2::Request.
58
+ def followings(user_id: nil, user_name: nil, page: 1, count: 20)
59
+ Youku::V2::Request.new "#{BASE_URI}/followings.json", {
60
+ client_id: client.client_id,
61
+ user_id: user_id,
62
+ user_name: user_name,
63
+ page: page,
64
+ count: count,
65
+ }
66
+ end
67
+
68
+ # Public: Get the users a given user is following.
69
+ #
70
+ # See: http://open.youku.com/docs?id=27
71
+ #
72
+ # user_id - The String Youku user ID.
73
+ # user_name - The String Youku user name.
74
+ # page - The Integer page number.
75
+ # count - The Integer page size.
76
+ #
77
+ # Returns the instance of Youku::V2::Request.
78
+ def followers(user_id: nil, user_name: nil, page: 1, count: 20)
79
+ Youku::V2::Request.new "#{BASE_URI}/followers.json", {
80
+ client_id: client.client_id,
81
+ user_id: user_id,
82
+ user_name: user_name,
83
+ page: page,
84
+ count: count,
85
+ }
86
+ end
87
+ end
37
88
  end
38
89
  end
39
90
  end
@@ -3,6 +3,68 @@ module Youku
3
3
  class Videos < Base
4
4
  BASE_URI = "#{BASE_URI}/videos"
5
5
 
6
+ # Public: Get basic information by video ID
7
+ #
8
+ # See: http://open.youku.com/docs?id=44
9
+ #
10
+ # video_id - The video ID.
11
+ # video_url - The video's URL.
12
+ #
13
+ # Returns the instance of Youku::V2::Request.
14
+ def show_basic(video_id: nil, video_url: nil)
15
+ Youku::V2::Request.new "#{BASE_URI}/show_basic.json", {
16
+ client_id: client.client_id,
17
+ video_id: video_id,
18
+ video_url: video_url,
19
+ }
20
+ end
21
+
22
+ # Public: Get basic information by video IDs
23
+ #
24
+ # See: http://open.youku.com/docs?id=45
25
+ #
26
+ # video_ids - The String video IDs.
27
+ #
28
+ # Returns the instance of Youku::V2::Request.
29
+ def show_basic_batch(video_ids: nil)
30
+ Youku::V2::Request.new "#{BASE_URI}/show_basic_batch.json", {
31
+ client_id: client.client_id,
32
+ video_ids: video_ids,
33
+ }
34
+ end
35
+
36
+ # Public: Get video by ID
37
+ #
38
+ # See: http://open.youku.com/docs?id=46
39
+ #
40
+ # video_id - The String video ID.
41
+ # ext - The String video extension information.
42
+ #
43
+ # Returns the instance of Youku::V2::Request.
44
+ def show(video_id: nil, ext: nil)
45
+ Youku::V2::Request.new "#{BASE_URI}/show.json", {
46
+ client_id: client.client_id,
47
+ video_id: video_id,
48
+ ext: ext,
49
+ }
50
+ end
51
+
52
+ # Public: Get videos by IDs
53
+ #
54
+ # See: http://open.youku.com/docs?id=47
55
+ #
56
+ # video_ids - The comma separated String of video IDs.
57
+ # ext - The String video extension information.
58
+ #
59
+ # Returns the instance of Youku::V2::Request.
60
+ def show_batch(video_ids: nil, ext: nil)
61
+ Youku::V2::Request.new "#{BASE_URI}/show_batch.json", {
62
+ client_id: client.client_id,
63
+ video_ids: video_ids,
64
+ ext: ext,
65
+ }
66
+ end
67
+
6
68
  # Public: Get videos for given Youku user.
7
69
  #
8
70
  # See: http://open.youku.com/docs?id=49
@@ -21,42 +83,82 @@ module Youku
21
83
  user_name: user_name,
22
84
  orderby: orderby,
23
85
  page: page,
24
- count: count
86
+ count: count,
25
87
  }
26
88
  end
27
89
 
28
- # Public: Get video by ID
90
+ # Public: Get videos that relate to another video.
29
91
  #
30
- # See: http://open.youku.com/docs?id=46
92
+ # See: http://open.youku.com/docs?id=52
31
93
  #
32
94
  # video_id - The String video ID.
33
- # ext - The String video extension information.
95
+ # count - The Integer page size.
34
96
  #
35
97
  # Returns the instance of Youku::V2::Request.
36
- def show(video_id, ext: nil)
37
- Youku::V2::Request.new "#{BASE_URI}/show.json", {
98
+ def by_related(video_id: nil, count: 20)
99
+ Youku::V2::Request.new "#{BASE_URI}/by_related.json", {
38
100
  client_id: client.client_id,
39
101
  video_id: video_id,
40
- ext: ext
102
+ count: count,
41
103
  }
42
104
  end
43
105
 
44
- # Public: Get videos by IDs
106
+ # Public: Get videos for a given category.
45
107
  #
46
- # See: http://open.youku.com/docs?id=47
108
+ # See: http://open.youku.com/docs?id=57
47
109
  #
48
- # video_ids - The comma separated String of video IDs.
49
- # ext - The String video extension information.
110
+ # category - The String category.
111
+ # genre - The String genre.
112
+ # period - The String period.
113
+ # orderby - The String order of videos.
114
+ # page - The Integer page number.
115
+ # count - The Integer page size.
50
116
  #
51
117
  # Returns the instance of Youku::V2::Request.
52
- def show_batch(video_ids: nil, ext: nil)
53
- Youku::V2::Request.new "#{BASE_URI}/show_batch.json", {
118
+ def by_category(category: nil, genre: nil, period: nil, orderby: 'view-count', page: 1, count: 20)
119
+ Youku::V2::Request.new "#{BASE_URI}/by_category.json", {
54
120
  client_id: client.client_id,
55
- video_ids: video_ids,
56
- ext: ext
121
+ category: category,
122
+ genre: genre,
123
+ period: period,
124
+ orderby: orderby,
125
+ page: page,
126
+ count: count,
57
127
  }
58
128
  end
59
129
 
130
+ # Public: Get favourite API.
131
+ #
132
+ # Returns the instance of Youku::V2::Videos::Favorite.
133
+ def favorite
134
+ Favorite.new(client)
135
+ end
136
+
137
+ class Favorite < Base
138
+ BASE_URI = "#{BASE_URI}/favorite"
139
+
140
+ # Public: Get a given user's favorite videos
141
+ #
142
+ # See: http://open.youku.com/docs?id=54
143
+ #
144
+ # user_id - The String Youku user ID.
145
+ # user_name - The String Youku user name.
146
+ # orderby - The String order of videos.
147
+ # page - The Integer page number.
148
+ # count - The Integer page size.
149
+ #
150
+ # Returns the instance of Youku::V2::Request.
151
+ def by_user(user_id: nil, user_name: nil, orderby: 'favorite-time', page: 1, count: 20)
152
+ Youku::V2::Request.new "#{BASE_URI}/by_user.json", {
153
+ client_id: client.client_id,
154
+ user_id: user_id,
155
+ user_name: user_name,
156
+ orderby: orderby,
157
+ page: page,
158
+ count: count,
159
+ }
160
+ end
161
+ end
60
162
  end
61
163
  end
62
164
  end
data/lib/youku/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Youku
2
2
 
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
 
5
5
  end
@@ -21,4 +21,63 @@ describe Youku::V2::Comments do
21
21
 
22
22
  it_should_behave_like 'a base Youku API V2 requests'
23
23
  end
24
+
25
+ describe '#show' do
26
+ let(:url) { 'https://openapi.youku.com/v2/comments/show.json' }
27
+ let(:query) { {
28
+ client_id: client.client_id,
29
+ comment_id: 123,
30
+ } }
31
+
32
+ before do
33
+ stub_request(:get, url).with(query: query).to_return(status: 200)
34
+ end
35
+
36
+ subject { client.comments.show(comment_id: 123) }
37
+
38
+ it_should_behave_like 'a base Youku API V2 requests'
39
+ end
40
+
41
+ describe '#show_batch' do
42
+ let(:url) { 'https://openapi.youku.com/v2/comments/show_batch.json' }
43
+ let(:query) { {
44
+ client_id: client.client_id,
45
+ comment_ids: 123,
46
+ } }
47
+
48
+ before do
49
+ stub_request(:get, url).with(query: query).to_return(status: 200)
50
+ end
51
+
52
+ subject { client.comments.show_batch(comment_ids: 123) }
53
+
54
+ it_should_behave_like 'a base Youku API V2 requests'
55
+ end
56
+
57
+ describe '#hot' do
58
+ subject { client.comments.hot }
59
+
60
+ it { expect(subject).to be_a Youku::V2::Comments::Hot }
61
+ it { expect(subject.client).to eq client }
62
+ end
63
+
64
+ describe '::Hot' do
65
+ describe '#by_video' do
66
+ let(:url) { 'https://openapi.youku.com/v2/comments/hot/by_video.json' }
67
+ let(:query) { {
68
+ client_id: client.client_id,
69
+ video_id: 123,
70
+ page: 1,
71
+ count: 20
72
+ } }
73
+
74
+ before do
75
+ stub_request(:get, url).with(query: query).to_return(status: 200)
76
+ end
77
+
78
+ subject { client.comments.hot.by_video(video_id: 123) }
79
+
80
+ it_should_behave_like 'a base Youku API V2 requests'
81
+ end
82
+ end
24
83
  end
@@ -3,7 +3,6 @@ require 'spec_helper'
3
3
  describe Youku::V2::Users do
4
4
 
5
5
  let(:client) { Youku::Client.new(client_id: 'client-id') }
6
- let(:users) { Youku::V2::Users.new(client) }
7
6
 
8
7
  describe '#show_batch' do
9
8
  let(:url) { 'https://openapi.youku.com/v2/users/show_batch.json' }
@@ -17,7 +16,7 @@ describe Youku::V2::Users do
17
16
  stub_request(:get, url).with(query: query).to_return(status: 200)
18
17
  end
19
18
 
20
- subject { users.show_batch(user_names: 'jackie_chan') }
19
+ subject { client.users.show_batch(user_names: 'jackie_chan') }
21
20
 
22
21
  it_should_behave_like 'a base Youku API V2 requests'
23
22
  end
@@ -34,8 +33,55 @@ describe Youku::V2::Users do
34
33
  stub_request(:get, url).with(query: query).to_return(status: 200)
35
34
  end
36
35
 
37
- subject { users.show(user_name: 'jackie_chan') }
36
+ subject { client.users.show(user_name: 'jackie_chan') }
38
37
 
39
38
  it_should_behave_like 'a base Youku API V2 requests'
40
39
  end
40
+
41
+ describe '#friendship' do
42
+ subject { client.users.friendship }
43
+
44
+ it { expect(subject).to be_a Youku::V2::Users::Friendship }
45
+ it { expect(subject.client).to eq client }
46
+ end
47
+
48
+ describe '::Friendship' do
49
+ describe '#followings' do
50
+ let(:url) { 'https://openapi.youku.com/v2/users/friendship/followings.json' }
51
+ let(:query) { {
52
+ client_id: client.client_id,
53
+ user_id: '',
54
+ user_name: 'jackie_chan',
55
+ page: 1,
56
+ count: 20,
57
+ } }
58
+
59
+ before do
60
+ stub_request(:get, url).with(query: query).to_return(status: 200)
61
+ end
62
+
63
+ subject { client.users.friendship.followings(user_name: 'jackie_chan') }
64
+
65
+ it_should_behave_like 'a base Youku API V2 requests'
66
+ end
67
+
68
+ describe '#followers' do
69
+ let(:url) { 'https://openapi.youku.com/v2/users/friendship/followers.json' }
70
+ let(:query) { {
71
+ client_id: client.client_id,
72
+ user_id: '',
73
+ user_name: 'jackie_chan',
74
+ page: 1,
75
+ count: 20,
76
+ } }
77
+
78
+ before do
79
+ stub_request(:get, url).with(query: query).to_return(status: 200)
80
+ end
81
+
82
+ subject { client.users.friendship.followers(user_name: 'jackie_chan') }
83
+
84
+ it_should_behave_like 'a base Youku API V2 requests'
85
+ end
86
+ end
41
87
  end
@@ -3,21 +3,36 @@ require 'spec_helper'
3
3
  describe Youku::V2::Videos do
4
4
 
5
5
  let(:client) { Youku::Client.new(client_id: 'client-id') }
6
- let(:videos) { Youku::V2::Videos.new(client) }
7
6
 
8
- describe '#show_batch' do
9
- let(:url) { 'https://openapi.youku.com/v2/videos/show_batch.json' }
7
+ describe '#show_basic' do
8
+ let(:url) { 'https://openapi.youku.com/v2/videos/show_basic.json' }
10
9
  let(:query) { {
11
10
  client_id: client.client_id,
12
- video_ids: 123,
13
- ext: '',
11
+ video_id: 123,
12
+ video_url: '',
14
13
  } }
15
14
 
16
15
  before do
17
16
  stub_request(:get, url).with(query: query).to_return(status: 200)
18
17
  end
19
18
 
20
- subject { videos.show_batch(video_ids: 123) }
19
+ subject { client.videos.show_basic(video_id: 123) }
20
+
21
+ it_should_behave_like 'a base Youku API V2 requests'
22
+ end
23
+
24
+ describe '#show_basic_batch' do
25
+ let(:url) { 'https://openapi.youku.com/v2/videos/show_basic_batch.json' }
26
+ let(:query) { {
27
+ client_id: client.client_id,
28
+ video_ids: 123,
29
+ } }
30
+
31
+ before do
32
+ stub_request(:get, url).with(query: query).to_return(status: 200)
33
+ end
34
+
35
+ subject { client.videos.show_basic_batch(video_ids: 123) }
21
36
 
22
37
  it_should_behave_like 'a base Youku API V2 requests'
23
38
  end
@@ -34,7 +49,24 @@ describe Youku::V2::Videos do
34
49
  stub_request(:get, url).with(query: query).to_return(status: 200)
35
50
  end
36
51
 
37
- subject { videos.show(123) }
52
+ subject { client.videos.show(video_id: 123) }
53
+
54
+ it_should_behave_like 'a base Youku API V2 requests'
55
+ end
56
+
57
+ describe '#show_batch' do
58
+ let(:url) { 'https://openapi.youku.com/v2/videos/show_batch.json' }
59
+ let(:query) { {
60
+ client_id: client.client_id,
61
+ video_ids: 123,
62
+ ext: '',
63
+ } }
64
+
65
+ before do
66
+ stub_request(:get, url).with(query: query).to_return(status: 200)
67
+ end
68
+
69
+ subject { client.videos.show_batch(video_ids: 123) }
38
70
 
39
71
  it_should_behave_like 'a base Youku API V2 requests'
40
72
  end
@@ -47,6 +79,44 @@ describe Youku::V2::Videos do
47
79
  user_name: '',
48
80
  orderby: 'published',
49
81
  page: 1,
82
+ count: 20,
83
+ } }
84
+
85
+ before do
86
+ stub_request(:get, url).with(query: query).to_return(status: 200)
87
+ end
88
+
89
+ subject { client.videos.by_user(user_id: 123) }
90
+
91
+ it_should_behave_like 'a base Youku API V2 requests'
92
+ end
93
+
94
+ describe '#by_related' do
95
+ let(:url) { 'https://openapi.youku.com/v2/videos/by_related.json' }
96
+ let(:query) { {
97
+ client_id: client.client_id,
98
+ video_id: 123,
99
+ count: 20,
100
+ } }
101
+
102
+ before do
103
+ stub_request(:get, url).with(query: query).to_return(status: 200)
104
+ end
105
+
106
+ subject { client.videos.by_related(video_id: 123) }
107
+
108
+ it_should_behave_like 'a base Youku API V2 requests'
109
+ end
110
+
111
+ describe '#by_category' do
112
+ let(:url) { 'https://openapi.youku.com/v2/videos/by_category.json' }
113
+ let(:query) { {
114
+ client_id: client.client_id,
115
+ category: 123,
116
+ genre: 456,
117
+ period: 789,
118
+ orderby: 'view-count',
119
+ page: 1,
50
120
  count: 20
51
121
  } }
52
122
 
@@ -54,9 +124,37 @@ describe Youku::V2::Videos do
54
124
  stub_request(:get, url).with(query: query).to_return(status: 200)
55
125
  end
56
126
 
57
- subject { videos.by_user(user_id: 123) }
127
+ subject { client.videos.by_category(category: 123, genre: 456, period: 789) }
58
128
 
59
129
  it_should_behave_like 'a base Youku API V2 requests'
60
130
  end
61
131
 
132
+ describe '#favorite' do
133
+ subject { client.videos.favorite }
134
+
135
+ it { expect(subject).to be_a Youku::V2::Videos::Favorite }
136
+ it { expect(subject.client).to eq client }
137
+ end
138
+
139
+ describe '::Favorite' do
140
+ describe '#by_user' do
141
+ let(:url) { 'https://openapi.youku.com/v2/videos/favorite/by_user.json' }
142
+ let(:query) { {
143
+ client_id: client.client_id,
144
+ user_id: 123,
145
+ user_name: '',
146
+ orderby: 'favorite-time',
147
+ page: 1,
148
+ count: 20
149
+ } }
150
+
151
+ before do
152
+ stub_request(:get, url).with(query: query).to_return(status: 200)
153
+ end
154
+
155
+ subject { client.videos.favorite.by_user(user_id: 123) }
156
+
157
+ it_should_behave_like 'a base Youku API V2 requests'
158
+ end
159
+ end
62
160
  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.2
4
+ version: 0.0.3
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-11-30 00:00:00.000000000 Z
13
+ date: 2015-12-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: typhoeus