yify 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/Gemfile +5 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +276 -0
  6. data/Rakefile +31 -0
  7. data/lib/yify.rb +20 -0
  8. data/lib/yify/client.rb +184 -0
  9. data/lib/yify/models/api_response.rb +8 -0
  10. data/lib/yify/models/base.rb +10 -0
  11. data/lib/yify/models/comment.rb +15 -0
  12. data/lib/yify/models/movie.rb +54 -0
  13. data/lib/yify/models/profile.rb +10 -0
  14. data/lib/yify/models/requested_movie.rb +17 -0
  15. data/lib/yify/models/session.rb +10 -0
  16. data/lib/yify/models/upcoming_movie.rb +15 -0
  17. data/lib/yify/models/user.rb +19 -0
  18. data/lib/yify/response.rb +60 -0
  19. data/lib/yify/support/utils.rb +30 -0
  20. data/lib/yify/version.rb +3 -0
  21. data/spec/fixtures/vcr_cassettes/Yify_Client/should_add_a_request.yml +43 -0
  22. data/spec/fixtures/vcr_cassettes/Yify_Client/should_edit_a_profile.yml +42 -0
  23. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_a_profile.yml +44 -0
  24. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_movie_comments.yml +89 -0
  25. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_movie_details.yml +60 -0
  26. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_requests_list.yml +52 -0
  27. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_upcoming_movies.yml +188 -0
  28. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_user_details.yml +48 -0
  29. data/spec/fixtures/vcr_cassettes/Yify_Client/should_list_by_imdb_id.yml +55 -0
  30. data/spec/fixtures/vcr_cassettes/Yify_Client/should_list_movies.yml +45 -0
  31. data/spec/fixtures/vcr_cassettes/Yify_Client/should_login_a_user.yml +42 -0
  32. data/spec/fixtures/vcr_cassettes/Yify_Client/should_post_a_comment.yml +42 -0
  33. data/spec/fixtures/vcr_cassettes/Yify_Client/should_recover_passwords.yml +42 -0
  34. data/spec/fixtures/vcr_cassettes/Yify_Client/should_register_a_user.yml +42 -0
  35. data/spec/fixtures/vcr_cassettes/Yify_Client/should_reset_a_password.yml +42 -0
  36. data/spec/fixtures/vcr_cassettes/Yify_Client/should_vote_on_requests.yml +42 -0
  37. data/spec/models/api_response_spec.rb +6 -0
  38. data/spec/models/comment_spec.rb +13 -0
  39. data/spec/models/movie_spec.rb +53 -0
  40. data/spec/models/profile_spec.rb +21 -0
  41. data/spec/models/requested_movie_spec.rb +20 -0
  42. data/spec/models/session_spec.rb +8 -0
  43. data/spec/models/upcoming_movie_spec.rb +13 -0
  44. data/spec/models/user_spec.rb +17 -0
  45. data/spec/response_spec.rb +43 -0
  46. data/spec/spec_helper.rb +22 -0
  47. data/spec/support/utils_spec.rb +30 -0
  48. data/spec/yify_spec.rb +103 -0
  49. data/yify.gemspec +32 -0
  50. metadata +260 -0
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.re/api/login
6
+ body:
7
+ encoding: UTF-8
8
+ string: username=<USERNAME>&password=<PASSWORD>
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - HU Server 9001
17
+ Date:
18
+ - Sun, 19 Oct 2014 22:57:37 GMT
19
+ Content-Type:
20
+ - application/json
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Age:
28
+ - '0'
29
+ X-Cache:
30
+ - uncached
31
+ Accept-Ranges:
32
+ - bytes
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"userID":"<USERID>","username":"<USERNAME>","userRole":"Users","hash":"<HASH>"}'
40
+ http_version:
41
+ recorded_at: Sun, 19 Oct 2014 22:57:38 GMT
42
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.re/api/commentpost
6
+ body:
7
+ encoding: UTF-8
8
+ string: hash=<HASH>&text=RUBY%20FTW!&movieid=353
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - HU Server 9001
17
+ Date:
18
+ - Sun, 19 Oct 2014 23:35:20 GMT
19
+ Content-Type:
20
+ - application/json
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Age:
28
+ - '0'
29
+ X-Cache:
30
+ - uncached
31
+ Accept-Ranges:
32
+ - bytes
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"status":"successfully posted comment"}'
40
+ http_version:
41
+ recorded_at: Sun, 19 Oct 2014 23:35:21 GMT
42
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.re/api/sendresetpass
6
+ body:
7
+ encoding: UTF-8
8
+ string: email=<EMAIL>
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - FI Server 9001
17
+ Date:
18
+ - Mon, 20 Oct 2014 00:29:11 GMT
19
+ Content-Type:
20
+ - application/json
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Age:
28
+ - '0'
29
+ X-Cache:
30
+ - uncached
31
+ Accept-Ranges:
32
+ - bytes
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"status":"password reset code has been sent"}'
40
+ http_version:
41
+ recorded_at: Mon, 20 Oct 2014 00:34:27 GMT
42
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.re/api/register
6
+ body:
7
+ encoding: UTF-8
8
+ string: username=<USERNAME>&password=<PASSWORD>&email=<EMAIL>
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - UA Server 9001
17
+ Date:
18
+ - Sun, 19 Oct 2014 22:41:55 GMT
19
+ Content-Type:
20
+ - application/json
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Age:
28
+ - '0'
29
+ X-Cache:
30
+ - uncached
31
+ Accept-Ranges:
32
+ - bytes
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"status":"An activation email has been sent <EMAIL>"}'
40
+ http_version:
41
+ recorded_at: Sun, 19 Oct 2014 22:41:55 GMT
42
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.re/api/resetpassconfirm
6
+ body:
7
+ encoding: UTF-8
8
+ string: code=<CODE>&newpassword=<NEWPASSWORD>
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - UA Server 9001
17
+ Date:
18
+ - Mon, 20 Oct 2014 00:42:23 GMT
19
+ Content-Type:
20
+ - application/json
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Age:
28
+ - '0'
29
+ X-Cache:
30
+ - uncached
31
+ Accept-Ranges:
32
+ - bytes
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"status":"password has been changed"}'
40
+ http_version:
41
+ recorded_at: Mon, 20 Oct 2014 00:42:23 GMT
42
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.re/api/vote
6
+ body:
7
+ encoding: UTF-8
8
+ string: hash=<HASH>&requestid=1169
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - SK Server 9001
17
+ Date:
18
+ - Mon, 20 Oct 2014 07:57:51 GMT
19
+ Content-Type:
20
+ - application/json
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Age:
28
+ - '0'
29
+ X-Cache:
30
+ - uncached
31
+ Accept-Ranges:
32
+ - bytes
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"status":"Vote submission successful"}'
40
+ http_version:
41
+ recorded_at: Mon, 20 Oct 2014 00:18:43 GMT
42
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Models::ApiResponse do
4
+ it { should respond_to(:status) }
5
+ it { should respond_to(:error) }
6
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Models::Comment do
4
+ it { should respond_to(:comment_id) }
5
+ it { should respond_to(:comment_text) }
6
+ it { should respond_to(:date_added) }
7
+ it { should respond_to(:date_added_epoch) }
8
+ it { should respond_to(:user_id) }
9
+ it { should respond_to(:parent_comment_id) }
10
+ it { should respond_to(:user_name) }
11
+ it { should respond_to(:user_avatar) }
12
+ it { should respond_to(:user_group) }
13
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Models::Movie do
4
+ it { should respond_to(:age_rating) }
5
+ it { should respond_to(:cast_list) }
6
+ it { should respond_to(:cover_image) }
7
+ it { should respond_to(:date_uploaded) }
8
+ it { should respond_to(:date_uploaded_epoch) }
9
+ it { should respond_to(:director_list) }
10
+ it { should respond_to(:downloaded) }
11
+ it { should respond_to(:frame_rate) }
12
+ it { should respond_to(:genre) }
13
+ it { should respond_to(:genre1) }
14
+ it { should respond_to(:genre2) }
15
+ it { should respond_to(:imdb_code) }
16
+ it { should respond_to(:imdb_link) }
17
+ it { should respond_to(:language) }
18
+ it { should respond_to(:large_cover) }
19
+ it { should respond_to(:large_screenshot1) }
20
+ it { should respond_to(:large_screenshot2) }
21
+ it { should respond_to(:large_screenshot3) }
22
+ it { should respond_to(:long_description) }
23
+ it { should respond_to(:medium_cover) }
24
+ it { should respond_to(:medium_screenshot1) }
25
+ it { should respond_to(:medium_screenshot2) }
26
+ it { should respond_to(:medium_screenshot3) }
27
+ it { should respond_to(:movie_count) }
28
+ it { should respond_to(:movie_id) }
29
+ it { should respond_to(:movie_rating) }
30
+ it { should respond_to(:movie_runtime) }
31
+ it { should respond_to(:movie_title) }
32
+ it { should respond_to(:movie_title_clean) }
33
+ it { should respond_to(:movie_url) }
34
+ it { should respond_to(:movie_year) }
35
+ it { should respond_to(:quality) }
36
+ it { should respond_to(:resolution) }
37
+ it { should respond_to(:short_description) }
38
+ it { should respond_to(:size) }
39
+ it { should respond_to(:size_byte) }
40
+ it { should respond_to(:state) }
41
+ it { should respond_to(:subtitles) }
42
+ it { should respond_to(:torrent_hash) }
43
+ it { should respond_to(:torrent_magnet_url) }
44
+ it { should respond_to(:torrent_peers) }
45
+ it { should respond_to(:torrent_seeds) }
46
+ it { should respond_to(:torrent_url) }
47
+ it { should respond_to(:uploader) }
48
+ it { should respond_to(:uploader_uid) }
49
+ it { should respond_to(:uploader_notes) }
50
+ it { should respond_to(:youtube_trailer_id) }
51
+ it { should respond_to(:youtube_trailer_url) }
52
+ end
53
+
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Models::Profile do
4
+ it { should respond_to(:user_id) }
5
+ it { should respond_to(:user_name) }
6
+ it { should respond_to(:join_dated) }
7
+ it { should respond_to(:join_dated_epoch) }
8
+ it { should respond_to(:last_seen_date) }
9
+ it { should respond_to(:last_seen_date_epoch) }
10
+ it { should respond_to(:ip_address) }
11
+ it { should respond_to(:num_of_votes_left) }
12
+ it { should respond_to(:num_of_requests_left) }
13
+ it { should respond_to(:profile_active) }
14
+ it { should respond_to(:torrents_downloaded_count) }
15
+ it { should respond_to(:movies_requested_count) }
16
+ it { should respond_to(:comment_count) }
17
+ it { should respond_to(:chat_time_seconds) }
18
+ it { should respond_to(:avatar) }
19
+ it { should respond_to(:user_role) }
20
+ it { should respond_to(:about) }
21
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Models::RequestedMovie do
4
+ it { should respond_to(:movie_count) }
5
+ it { should respond_to(:request_id) }
6
+ it { should respond_to(:movie_title_clean) }
7
+ it { should respond_to(:movie_year) }
8
+ it { should respond_to(:movie_title) }
9
+ it { should respond_to(:imdb_code) }
10
+ it { should respond_to(:imdb_link) }
11
+ it { should respond_to(:cover_image) }
12
+ it { should respond_to(:short_description) }
13
+ it { should respond_to(:genre) }
14
+ it { should respond_to(:movie_rating) }
15
+ it { should respond_to(:date_added) }
16
+ it { should respond_to(:date_added_epoch) }
17
+ it { should respond_to(:votes) }
18
+ it { should respond_to(:user_id) }
19
+ it { should respond_to(:user_name) }
20
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Models::Session do
4
+ it { should respond_to(:hash) }
5
+ it { should respond_to(:user_id) }
6
+ it { should respond_to(:user_role) }
7
+ it { should respond_to(:username) }
8
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Models::UpcomingMovie do
4
+ it { should respond_to(:movie_title) }
5
+ it { should respond_to(:movie_cover) }
6
+ it { should respond_to(:imdb_code) }
7
+ it { should respond_to(:imdb_link) }
8
+ it { should respond_to(:uploader) }
9
+ it { should respond_to(:uploader_uid) }
10
+ it { should respond_to(:date_added) }
11
+ it { should respond_to(:date_added_epoch) }
12
+ it { should respond_to(:username) }
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Models::User do
4
+ it { should respond_to(:user_id) }
5
+ it { should respond_to(:user_name) }
6
+ it { should respond_to(:join_dated) }
7
+ it { should respond_to(:join_dated_epoch) }
8
+ it { should respond_to(:last_seen_date) }
9
+ it { should respond_to(:last_seen_date_epoch) }
10
+ it { should respond_to(:torrents_downloaded_count) }
11
+ it { should respond_to(:movies_requested_count) }
12
+ it { should respond_to(:comment_count) }
13
+ it { should respond_to(:chat_time_seconds) }
14
+ it { should respond_to(:avatar) }
15
+ it { should respond_to(:user_role) }
16
+ it { should respond_to(:about) }
17
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Response do
4
+ let(:klass) { Yify::Response.new({}, :movie) }
5
+
6
+ it "should expose a model" do
7
+ expect(klass.model).to eq(:movie)
8
+ end
9
+
10
+ it "should expose a response" do
11
+ expect(klass.response).to eq({})
12
+ end
13
+
14
+ it "should return a Movie" do
15
+ expect(klass.result).to be_a(Yify::Models::Movie)
16
+ end
17
+
18
+ it "shout return a UpcomingMovie" do
19
+ res = Yify::Response.new({}, :upcoming_movie)
20
+ expect(res.result).to be_a(Yify::Models::UpcomingMovie)
21
+ end
22
+
23
+ it "should return a Comment" do
24
+ res = Yify::Response.new({}, :comment)
25
+ expect(res.result).to be_a(Yify::Models::Comment)
26
+ end
27
+
28
+ it "should return a User" do
29
+ res = Yify::Response.new({}, :user)
30
+ expect(res.result).to be_a(Yify::Models::User)
31
+ end
32
+
33
+ it "should return a Session" do
34
+ res = Yify::Response.new({}, :session)
35
+ expect(res.result).to be_a(Yify::Models::Session)
36
+ end
37
+
38
+ it "should return a Profile" do
39
+ res = Yify::Response.new({}, :profile)
40
+ expect(res.result).to be_a(Yify::Models::Profile)
41
+ end
42
+
43
+ end