yify 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -229
  3. data/lib/yify.rb +7 -3
  4. data/lib/yify/client.rb +307 -95
  5. data/lib/yify/models/actor.rb +6 -0
  6. data/lib/yify/models/api_response.rb +0 -2
  7. data/lib/yify/models/base.rb +18 -0
  8. data/lib/yify/models/bookmark.rb +6 -0
  9. data/lib/yify/models/comment.rb +1 -9
  10. data/lib/yify/models/director.rb +6 -0
  11. data/lib/yify/models/movie.rb +0 -48
  12. data/lib/yify/models/parental_guide.rb +6 -0
  13. data/lib/yify/models/profile.rb +1 -5
  14. data/lib/yify/models/review.rb +6 -0
  15. data/lib/yify/models/session.rb +0 -4
  16. data/lib/yify/models/torrent.rb +6 -0
  17. data/lib/yify/models/user.rb +1 -13
  18. data/lib/yify/response.rb +1 -12
  19. data/lib/yify/support/utils.rb +24 -1
  20. data/lib/yify/version.rb +1 -1
  21. data/spec/fixtures/vcr_cassettes/Yify_Client/should_add_a_movie_bookmark.yml +59 -0
  22. data/spec/fixtures/vcr_cassettes/Yify_Client/should_delete_a_comment.yml +59 -0
  23. data/spec/fixtures/vcr_cassettes/Yify_Client/should_delete_a_movie_bookmark.yml +59 -0
  24. data/spec/fixtures/vcr_cassettes/Yify_Client/should_edit_a_user_profile.yml +61 -0
  25. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_a_user_key.yml +59 -0
  26. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_a_user_profile.yml +56 -0
  27. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_movie_bookmarks.yml +59 -0
  28. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_movie_comments.yml +106 -60
  29. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_movie_details.yml +42 -29
  30. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_movie_parental_guides.yml +106 -0
  31. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_movie_reviews.yml +285 -0
  32. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_movie_suggestions.yml +69 -0
  33. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_upcoming_movies.yml +31 -159
  34. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_user_details.yml +35 -16
  35. data/spec/fixtures/vcr_cassettes/Yify_Client/should_like_a_comment.yml +59 -0
  36. data/spec/fixtures/vcr_cassettes/Yify_Client/should_like_a_movie.yml +59 -0
  37. data/spec/fixtures/vcr_cassettes/Yify_Client/should_list_movies.yml +36 -14
  38. data/spec/fixtures/vcr_cassettes/Yify_Client/should_make_a_comment.yml +60 -0
  39. data/spec/fixtures/vcr_cassettes/Yify_Client/should_make_a_request.yml +60 -0
  40. data/spec/fixtures/vcr_cassettes/Yify_Client/should_recover_forgotten_passwords.yml +59 -0
  41. data/spec/fixtures/vcr_cassettes/Yify_Client/should_register_a_user.yml +29 -12
  42. data/spec/fixtures/vcr_cassettes/Yify_Client/should_report_a_comment.yml +59 -0
  43. data/spec/fixtures/vcr_cassettes/Yify_Client/should_reset_a_password.yml +29 -12
  44. data/spec/models/base_spec.rb +21 -0
  45. data/spec/response_spec.rb +7 -11
  46. data/spec/spec_helper.rb +8 -4
  47. data/spec/yify_spec.rb +97 -57
  48. data/yify.gemspec +1 -1
  49. metadata +44 -38
  50. data/lib/yify/models/requested_movie.rb +0 -17
  51. data/lib/yify/models/upcoming_movie.rb +0 -15
  52. data/spec/fixtures/vcr_cassettes/Yify_Client/should_add_a_request.yml +0 -43
  53. data/spec/fixtures/vcr_cassettes/Yify_Client/should_edit_a_profile.yml +0 -42
  54. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_a_profile.yml +0 -44
  55. data/spec/fixtures/vcr_cassettes/Yify_Client/should_get_requests_list.yml +0 -52
  56. data/spec/fixtures/vcr_cassettes/Yify_Client/should_login_a_user.yml +0 -42
  57. data/spec/fixtures/vcr_cassettes/Yify_Client/should_post_a_comment.yml +0 -42
  58. data/spec/fixtures/vcr_cassettes/Yify_Client/should_recover_passwords.yml +0 -42
  59. data/spec/fixtures/vcr_cassettes/Yify_Client/should_vote_on_requests.yml +0 -42
  60. data/spec/models/api_response_spec.rb +0 -6
  61. data/spec/models/comment_spec.rb +0 -13
  62. data/spec/models/movie_spec.rb +0 -53
  63. data/spec/models/profile_spec.rb +0 -21
  64. data/spec/models/requested_movie_spec.rb +0 -20
  65. data/spec/models/session_spec.rb +0 -8
  66. data/spec/models/upcoming_movie_spec.rb +0 -13
  67. data/spec/models/user_spec.rb +0 -17
@@ -0,0 +1,60 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.to/api/v2/make_comment
6
+ body:
7
+ encoding: UTF-8
8
+ string: application_key=<APPLICATION_KEY>&user_key=<USER_KEY>&movie_id=353&comment_text=Hello%20World%21
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Sun, 20 Sep 2015 21:26:13 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Content-Length:
28
+ - '282'
29
+ Connection:
30
+ - keep-alive
31
+ Cache-Control:
32
+ - public, s-maxage=21600
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Pragma:
36
+ - no-cache
37
+ Expires:
38
+ - "-1"
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ - SAMEORIGIN
42
+ X-Content-Type-Options:
43
+ - nosniff
44
+ - nosniff
45
+ Age:
46
+ - '0'
47
+ X-Cache:
48
+ - uncached
49
+ Accept-Ranges:
50
+ - bytes
51
+ X-Frontend:
52
+ - CA
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"status":"ok","status_message":"Comment has been successfully submitted","data":{"comment_id":379208,"user_id":<USER_ID>"movie_id":353,"comment_text":"Hello
56
+ World!"},"@meta":{"server_time":1442784373,"server_timezone":"Pacific\/Auckland","api_version":2,"execution_time":"9.66
57
+ ms"}}'
58
+ http_version:
59
+ recorded_at: Sun, 20 Sep 2015 21:26:13 GMT
60
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,60 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.to/api/v2/make_request
6
+ body:
7
+ encoding: UTF-8
8
+ string: application_key=<APPLICATION_KEY>&user_key=<USER_KEY>&movie_title=Hello%20World%21&request_message=Please%20ignore%20this%20request%21
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Sun, 20 Sep 2015 21:40:45 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Cache-Control:
32
+ - public, s-maxage=21600
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Pragma:
36
+ - no-cache
37
+ Expires:
38
+ - "-1"
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ - SAMEORIGIN
42
+ X-Content-Type-Options:
43
+ - nosniff
44
+ - nosniff
45
+ Age:
46
+ - '0'
47
+ X-Cache:
48
+ - uncached
49
+ Accept-Ranges:
50
+ - bytes
51
+ X-Frontend:
52
+ - CA
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"status":"ok","status_message":"Request has been successfully submitted","data":{"user_id":<USER_ID>"movie_title":"Hello
56
+ World!","request_message":"Please ignore this request!"},"@meta":{"server_time":1442785245,"server_timezone":"Pacific\/Auckland","api_version":2,"execution_time":"5.65
57
+ ms"}}'
58
+ http_version:
59
+ recorded_at: Sun, 20 Sep 2015 21:40:45 GMT
60
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.to/api/v2/user_forgot_password
6
+ body:
7
+ encoding: UTF-8
8
+ string: application_key=<APPLICATION_KEY>&email=jon%40capturethecastle.net
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Sun, 20 Sep 2015 04:38:58 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Cache-Control:
32
+ - public, s-maxage=21600
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Pragma:
36
+ - no-cache
37
+ Expires:
38
+ - "-1"
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ - SAMEORIGIN
42
+ X-Content-Type-Options:
43
+ - nosniff
44
+ - nosniff
45
+ Age:
46
+ - '0'
47
+ X-Cache:
48
+ - uncached
49
+ Accept-Ranges:
50
+ - bytes
51
+ X-Frontend:
52
+ - CA
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"status":"ok","status_message":"Reset password code has been sent","@meta":{"server_time":1442723938,"server_timezone":"Pacific\/Auckland","api_version":2,"execution_time":"6238.75
56
+ ms"}}'
57
+ http_version:
58
+ recorded_at: Sun, 20 Sep 2015 04:38:58 GMT
59
+ recorded_with: VCR 2.9.3
@@ -2,41 +2,58 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://yts.to/api/register
5
+ uri: http://yts.to/api/v2/user_register
6
6
  body:
7
7
  encoding: UTF-8
8
- string: username=<USERNAME>&password=<PASSWORD>&email=<EMAIL>
9
- headers: {}
8
+ string: application_key=<APPLICATION_KEY>&username=<USERNAME>&password=<PASSWORD>&email=<EMAIL>
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
10
16
  response:
11
17
  status:
12
18
  code: 200
13
19
  message: OK
14
20
  headers:
15
21
  Server:
16
- - UA Server 9001
22
+ - nginx
17
23
  Date:
18
- - Sun, 19 Oct 2014 22:41:55 GMT
24
+ - Sun, 20 Sep 2015 02:15:34 GMT
19
25
  Content-Type:
20
26
  - application/json
21
27
  Transfer-Encoding:
22
28
  - chunked
23
29
  Connection:
24
30
  - keep-alive
31
+ Cache-Control:
32
+ - public, s-maxage=21600
25
33
  Access-Control-Allow-Origin:
26
34
  - "*"
35
+ Pragma:
36
+ - no-cache
37
+ Expires:
38
+ - "-1"
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ - SAMEORIGIN
42
+ X-Content-Type-Options:
43
+ - nosniff
44
+ - nosniff
27
45
  Age:
28
46
  - '0'
29
47
  X-Cache:
30
48
  - uncached
31
49
  Accept-Ranges:
32
50
  - bytes
33
- X-Frame-Options:
34
- - SAMEORIGIN
35
- X-Content-Type-Options:
36
- - nosniff
51
+ X-Frontend:
52
+ - LU
37
53
  body:
38
54
  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
55
+ string: '{"status":"ok","status_message":"User was successfully registered","data":{"username":"<USERNAME>","email":"<EMAIL>","user_key":"<USER_KEY>"},"@meta":{"server_time":1442715101,"server_timezone":"Pacific\/Auckland","api_version":2,"execution_time":"7.31
56
+ ms"}}'
57
+ http_version:
58
+ recorded_at: Sun, 20 Sep 2015 02:11:41 GMT
42
59
  recorded_with: VCR 2.9.3
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://yts.to/api/v2/report_comment
6
+ body:
7
+ encoding: UTF-8
8
+ string: application_key=<APPLICATION_KEY>&user_key=<USER_KEY>&comment_id=379208
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Sun, 20 Sep 2015 21:36:20 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Content-Length:
28
+ - '236'
29
+ Connection:
30
+ - keep-alive
31
+ Cache-Control:
32
+ - public, s-maxage=21600
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Pragma:
36
+ - no-cache
37
+ Expires:
38
+ - "-1"
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ - SAMEORIGIN
42
+ X-Content-Type-Options:
43
+ - nosniff
44
+ - nosniff
45
+ Age:
46
+ - '0'
47
+ X-Cache:
48
+ - uncached
49
+ Accept-Ranges:
50
+ - bytes
51
+ X-Frontend:
52
+ - CA
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"status":"ok","status_message":"Comment has been successfully reported","data":{"comment_id":379208,"user_id":1247782},"@meta":{"server_time":1442784980,"server_timezone":"Pacific\/Auckland","api_version":2,"execution_time":"7.86
56
+ ms"}}'
57
+ http_version:
58
+ recorded_at: Sun, 20 Sep 2015 21:36:20 GMT
59
+ recorded_with: VCR 2.9.3
@@ -2,41 +2,58 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://yts.to/api/resetpassconfirm
5
+ uri: http://yts.to/api/v2/user_reset_password
6
6
  body:
7
7
  encoding: UTF-8
8
- string: code=<CODE>&newpassword=<NEWPASSWORD>
9
- headers: {}
8
+ string: application_key=<APPLICATION_KEY>&reset_code=<PASSWORD_RESET_CODE>&new_password=<PASSWORD>
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
10
16
  response:
11
17
  status:
12
18
  code: 200
13
19
  message: OK
14
20
  headers:
15
21
  Server:
16
- - UA Server 9001
22
+ - nginx
17
23
  Date:
18
- - Mon, 20 Oct 2014 00:42:23 GMT
24
+ - Sun, 20 Sep 2015 04:49:45 GMT
19
25
  Content-Type:
20
26
  - application/json
21
27
  Transfer-Encoding:
22
28
  - chunked
23
29
  Connection:
24
30
  - keep-alive
31
+ Cache-Control:
32
+ - public, s-maxage=21600
25
33
  Access-Control-Allow-Origin:
26
34
  - "*"
35
+ Pragma:
36
+ - no-cache
37
+ Expires:
38
+ - "-1"
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ - SAMEORIGIN
42
+ X-Content-Type-Options:
43
+ - nosniff
44
+ - nosniff
27
45
  Age:
28
46
  - '0'
29
47
  X-Cache:
30
48
  - uncached
31
49
  Accept-Ranges:
32
50
  - bytes
33
- X-Frame-Options:
34
- - SAMEORIGIN
35
- X-Content-Type-Options:
36
- - nosniff
51
+ X-Frontend:
52
+ - DE
37
53
  body:
38
54
  encoding: UTF-8
39
- string: '{"status":"password has been changed"}'
40
- http_version:
41
- recorded_at: Mon, 20 Oct 2014 00:42:23 GMT
55
+ string: '{"status":"ok","status_message":"User password was successfully changed","data":{"username":"<USERNAME>","email":"<EMAIL>","user_key":"<USER_KEY>"},"@meta":{"server_time":1442724585,"server_timezone":"Pacific\/Auckland","api_version":2,"execution_time":"9.72
56
+ ms"}}'
57
+ http_version:
58
+ recorded_at: Sun, 20 Sep 2015 04:49:45 GMT
42
59
  recorded_with: VCR 2.9.3
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yify::Models::Base do
4
+
5
+ module Yify
6
+ module Models
7
+ class Foo < Base
8
+ end
9
+ end
10
+ end
11
+
12
+ it "should create attributes dynamically" do
13
+ model = Yify::Models::Base.new({ :hi => "hello" })
14
+ expect(model.hi).to eq("hello")
15
+ end
16
+
17
+ it "should create attributes as models if they exist" do
18
+ model = Yify::Models::Base.new({ :foos => [ :name => "I am foo" ] })
19
+ expect(model.foos.first).to be_kind_of(Yify::Models::Foo)
20
+ end
21
+ end
@@ -1,42 +1,38 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Yify::Response do
4
- let(:klass) { Yify::Response.new({}, :movie) }
4
+ let(:data) { { "data" => { "hi" => "hello" } } }
5
+ let(:klass) { Yify::Response.new(data, :movie) }
5
6
 
6
7
  it "should expose a model" do
7
8
  expect(klass.model).to eq(:movie)
8
9
  end
9
10
 
10
11
  it "should expose a response" do
11
- expect(klass.response).to eq({})
12
+ expect(klass.response).to eq(data)
12
13
  end
13
14
 
14
15
  it "should return a Movie" do
15
16
  expect(klass.result).to be_a(Yify::Models::Movie)
16
17
  end
17
18
 
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
19
  it "should return a Comment" do
24
- res = Yify::Response.new({}, :comment)
20
+ res = Yify::Response.new(data, :comment)
25
21
  expect(res.result).to be_a(Yify::Models::Comment)
26
22
  end
27
23
 
28
24
  it "should return a User" do
29
- res = Yify::Response.new({}, :user)
25
+ res = Yify::Response.new(data, :user)
30
26
  expect(res.result).to be_a(Yify::Models::User)
31
27
  end
32
28
 
33
29
  it "should return a Session" do
34
- res = Yify::Response.new({}, :session)
30
+ res = Yify::Response.new(data, :session)
35
31
  expect(res.result).to be_a(Yify::Models::Session)
36
32
  end
37
33
 
38
34
  it "should return a Profile" do
39
- res = Yify::Response.new({}, :profile)
35
+ res = Yify::Response.new(data, :profile)
40
36
  expect(res.result).to be_a(Yify::Models::Profile)
41
37
  end
42
38