yify 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/README.md +156 -29
- data/lib/yify/client.rb +21 -13
- data/lib/yify/support/utils.rb +5 -0
- data/lib/yify/version.rb +1 -1
- data/spec/yify_spec.rb +11 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f96a332480dd0b6c5883fbc666be0b5be4b9d39
|
4
|
+
data.tar.gz: 37c3caca1ef4112448b3138621803bcffd02ed66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93cb98f0d25cac232064fa1270b57b9d4027eac81ed4819ff846a61c0e0d30cf427f06ede1c888cee457f4da5f98ea54aa13ee05206da874edaffcf8ab0600fd
|
7
|
+
data.tar.gz: 7abffdb88f928a3bc77e6401c403cb392819e3799a3200f9f8b54503602479554cb1da81105cdbde485d4c8dbab9a23a53156d7abb632e7b6d810ad408f351fd
|
data/README.md
CHANGED
@@ -8,55 +8,182 @@ A Ruby wrapper for the [Yify Torrents API](https://yts.to/api)
|
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
```ruby
|
12
|
+
gem 'yify'
|
13
|
+
```
|
13
14
|
And then execute:
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
```ruby
|
17
|
+
$ bundle
|
18
|
+
```
|
17
19
|
Or install it yourself as:
|
18
20
|
|
19
|
-
|
21
|
+
```ruby
|
22
|
+
$ gem install yify
|
23
|
+
```
|
20
24
|
|
21
25
|
## Usage
|
22
26
|
|
23
27
|
Require Yify in your project:
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
```ruby
|
30
|
+
require 'yify'
|
31
|
+
```
|
32
|
+
|
33
|
+
##### Configuration
|
34
|
+
|
35
|
+
If you plan on making POST requests you must provide an `application_key` by
|
36
|
+
requesting one [here](https://yts.to/contact). Please note that the email from
|
37
|
+
Yify will be in your spam folder 99.9% of the time, so check there :)
|
38
|
+
|
39
|
+
You can configure your Yify client by passing in your `application_key` directly,
|
40
|
+
like so:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
client = Yify::Client.new("1235dsfjkdladfs")
|
44
|
+
client.application_key
|
45
|
+
=> "1235dsfjkdladfs"
|
46
|
+
```
|
47
|
+
|
48
|
+
Alternatively you can set a `yify_application_key` environment variable and that
|
49
|
+
will be picked up automatically:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
ENV["yify_application_key"] = "1235dsfjkdladfs"
|
53
|
+
|
54
|
+
client = Yify::Client.new
|
55
|
+
client.application_key
|
56
|
+
=> "1235dsfjkdladfs"
|
57
|
+
```
|
58
|
+
|
59
|
+
Now you can make POST requests and the `application_key` will be set for you,
|
60
|
+
no need to pass it as a param every time:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
client.user_get_key({ username: "hello", password: "world" })
|
64
|
+
|
65
|
+
=> #<Yify::Response:0x007f90f512f010
|
66
|
+
@model=:session,
|
67
|
+
@response=
|
68
|
+
{"status"=>"ok",
|
69
|
+
"status_message"=>"User successfully logged in",
|
70
|
+
"data"=>
|
71
|
+
{"user_id"=>123456,
|
72
|
+
"username"=>"hello",
|
73
|
+
"email"=>"hello@world.com",
|
74
|
+
"user_key"=>"12345678910abcdefghij"},
|
75
|
+
"@meta"=>
|
76
|
+
{"server_time"=>1442866362,
|
77
|
+
"server_timezone"=>"Pacific/Auckland",
|
78
|
+
"api_version"=>2,
|
79
|
+
"execution_time"=>"5.02 ms"}},
|
80
|
+
@result=
|
81
|
+
#<Yify::Models::Session:0x007f90f512dd78
|
82
|
+
@attribute_set=#<Virtus::AttributeSet:0x007f90f5132b20>,
|
83
|
+
@email="hello@world.com",
|
84
|
+
@user_id=123456,
|
85
|
+
@user_key="12345678910abcdefghij", # You will need this to make requests on behalf of the user
|
86
|
+
@username="hello">>
|
87
|
+
```
|
88
|
+
|
89
|
+
##### Example Response
|
90
|
+
|
91
|
+
This gem translates the raw JSON coming back from Yify into full fledged Ruby objects, like this:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
client = Yify::Client.new
|
95
|
+
client.list_upcoming
|
96
|
+
client.result
|
97
|
+
|
98
|
+
=> [#<Yify::Models::Movie:0x007f88675d27c0
|
99
|
+
@attribute_set=#<Virtus::AttributeSet:0x007f88675cb560>,
|
100
|
+
@date_added="2015-09-22 08:32:41",
|
101
|
+
@date_added_unix=1442867561,
|
102
|
+
@imdb_code="tt2582496",
|
103
|
+
@medium_cover_image=
|
104
|
+
"http://s.ynet.io/assets/images/upcoming/14428675626.jpg",
|
105
|
+
@title="Me and Earl and the Dying Girl",
|
106
|
+
@year=2015>,
|
107
|
+
#<Yify::Models::Movie:0x007f88675b9f40
|
108
|
+
@attribute_set=#<Virtus::AttributeSet:0x007f8867582888>,
|
109
|
+
@date_added="2015-09-19 04:18:56",
|
110
|
+
@date_added_unix=1442593136,
|
111
|
+
@imdb_code="tt0096926",
|
112
|
+
@medium_cover_image=
|
113
|
+
"http://s.ynet.io/assets/images/upcoming/144259313649.jpg",
|
114
|
+
@title="The Big Picture",
|
115
|
+
@year=1989>,
|
116
|
+
#<Yify::Models::Movie:0x007f8867578608
|
117
|
+
...
|
118
|
+
]>
|
119
|
+
```
|
37
120
|
|
38
121
|
A `Yify::Response` will always return an untouched hash as well, like this:
|
39
122
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
123
|
+
```ruby
|
124
|
+
client = Yify::Client.new
|
125
|
+
client.list_upcoming
|
126
|
+
client.response
|
127
|
+
|
128
|
+
=> {"status"=>"ok",
|
129
|
+
"status_message"=>"Query was successful",
|
130
|
+
"data"=>
|
131
|
+
{"upcoming_movies_count"=>4,
|
132
|
+
"upcoming_movies"=>
|
133
|
+
[{"title"=>"Me and Earl and the Dying Girl",
|
134
|
+
"year"=>2015,
|
135
|
+
"imdb_code"=>"tt2582496",
|
136
|
+
"medium_cover_image"=>
|
137
|
+
"http://s.ynet.io/assets/images/upcoming/14428675626.jpg",
|
138
|
+
"date_added"=>"2015-09-22 08:32:41",
|
139
|
+
"date_added_unix"=>1442867561},
|
140
|
+
{"title"=>"The Big Picture",
|
141
|
+
"year"=>1989,
|
142
|
+
"imdb_code"=>"tt0096926",
|
143
|
+
"medium_cover_image"=>
|
144
|
+
"http://s.ynet.io/assets/images/upcoming/144259313649.jpg",
|
145
|
+
"date_added"=>"2015-09-19 04:18:56",
|
146
|
+
"date_added_unix"=>1442593136}
|
147
|
+
...
|
148
|
+
]},
|
149
|
+
"@meta"=>
|
150
|
+
{"server_time"=>1442868382,
|
151
|
+
"server_timezone"=>"Pacific/Auckland",
|
152
|
+
"api_version"=>2,
|
153
|
+
"execution_time"=>"1.62 ms"}},
|
154
|
+
```
|
155
|
+
|
156
|
+
## API Documentation
|
44
157
|
|
45
|
-
|
46
|
-
|
158
|
+
You can view the full YTS API documentation [here](https://yts.to/api). Every
|
159
|
+
request documented is implemented by this gem, please file an issue if you find
|
160
|
+
a request that is not implemented.
|
47
161
|
|
48
|
-
|
49
|
-
POST request. You can request an `application_key` [here](https://yts.to/contact).
|
162
|
+
## Testing
|
50
163
|
|
164
|
+
This gem uses [dotenv](https://github.com/bkeepers/dotenv) to manage necessary
|
165
|
+
environment variables. After cloning this repo you will need to set the
|
166
|
+
following in a `.env` file in the root directory of this gem:
|
51
167
|
|
52
|
-
|
168
|
+
```ruby
|
169
|
+
yify_application_key=1234567890asdfg
|
170
|
+
user_key=1234567890asdfg
|
171
|
+
username=hello_world
|
172
|
+
username_variant=hello-world
|
173
|
+
password=pass1234
|
174
|
+
new_password=pass1234
|
175
|
+
email=hello@world.com
|
176
|
+
user_id=1234567,
|
177
|
+
ip_address=1.2.3.4.5
|
178
|
+
reset_code=fdase123
|
179
|
+
```
|
53
180
|
|
54
|
-
|
55
|
-
|
56
|
-
a request that is not implemented.
|
181
|
+
The values don't matter, this is just so vcr has something to reference when
|
182
|
+
filtering out sensitive data from the cassettes.
|
57
183
|
|
58
184
|
## Change Log
|
59
185
|
|
186
|
+
- **0.0.4:** Add application_key configuration
|
60
187
|
- **0.0.3:** Implement YTS API V2
|
61
188
|
- **0.0.2:** Update base_uri from yts.re -> yts.to
|
62
189
|
- **0.0.1:** Initial release
|
data/lib/yify/client.rb
CHANGED
@@ -2,10 +2,18 @@
|
|
2
2
|
|
3
3
|
module Yify
|
4
4
|
class Client
|
5
|
+
include Yify::Support::Utils
|
5
6
|
include HTTParty
|
7
|
+
|
8
|
+
attr_accessor :application_key
|
9
|
+
|
6
10
|
base_uri 'http://yts.to/api/v2'
|
7
11
|
format :json
|
8
12
|
|
13
|
+
def initialize(application_key = nil)
|
14
|
+
@application_key = application_key || ENV["yify_application_key"]
|
15
|
+
end
|
16
|
+
|
9
17
|
# [GET] list_movies
|
10
18
|
# See: https://yts.to/api#list_movies
|
11
19
|
#
|
@@ -149,7 +157,7 @@ module Yify
|
|
149
157
|
# @returns [Yify::Models::Session]
|
150
158
|
|
151
159
|
def user_get_key(params)
|
152
|
-
data = self.class.post("/user_get_key", { body: params })
|
160
|
+
data = self.class.post("/user_get_key", { body: post_params(params) })
|
153
161
|
Yify::Response.new(data, :session)
|
154
162
|
end
|
155
163
|
|
@@ -183,7 +191,7 @@ module Yify
|
|
183
191
|
# @returns Yify::Models::User
|
184
192
|
|
185
193
|
def user_edit_settings(params)
|
186
|
-
data = self.class.post("/user_edit_settings", { body: params })
|
194
|
+
data = self.class.post("/user_edit_settings", { body: post_params(params) })
|
187
195
|
Yify::Response.new(data, :user)
|
188
196
|
end
|
189
197
|
|
@@ -201,7 +209,7 @@ module Yify
|
|
201
209
|
# @returns Yify::Models::Session
|
202
210
|
|
203
211
|
def user_register(params)
|
204
|
-
data = self.class.post("/user_register", { body: params })
|
212
|
+
data = self.class.post("/user_register", { body: post_params(params) })
|
205
213
|
Yify::Response.new(data, :session)
|
206
214
|
end
|
207
215
|
|
@@ -217,7 +225,7 @@ module Yify
|
|
217
225
|
# @returns Yify::Models::ApiResponse
|
218
226
|
|
219
227
|
def user_forgot_password(params)
|
220
|
-
data = self.class.post("/user_forgot_password", { body: params })
|
228
|
+
data = self.class.post("/user_forgot_password", { body: post_params(params) })
|
221
229
|
Yify::Response.new(data, :api_response)
|
222
230
|
end
|
223
231
|
|
@@ -234,7 +242,7 @@ module Yify
|
|
234
242
|
# @returns Yify::Models::Session
|
235
243
|
|
236
244
|
def user_reset_password(params)
|
237
|
-
data = self.class.post("/user_reset_password", { body: params })
|
245
|
+
data = self.class.post("/user_reset_password", { body: post_params(params) })
|
238
246
|
Yify::Response.new(data, :session)
|
239
247
|
end
|
240
248
|
|
@@ -251,7 +259,7 @@ module Yify
|
|
251
259
|
# @returns Yify::Models::ApiResponse
|
252
260
|
|
253
261
|
def like_movie(params)
|
254
|
-
data = self.class.post("/like_movie", { body: params })
|
262
|
+
data = self.class.post("/like_movie", { body: post_params(params) })
|
255
263
|
Yify::Response.new(data, :api_response)
|
256
264
|
end
|
257
265
|
|
@@ -284,7 +292,7 @@ module Yify
|
|
284
292
|
# @returns Yify::Models::Bookmark
|
285
293
|
|
286
294
|
def add_movie_bookmark(params)
|
287
|
-
data = self.class.post("/add_movie_bookmark", { body: params })
|
295
|
+
data = self.class.post("/add_movie_bookmark", { body: post_params(params) })
|
288
296
|
Yify::Response.new(data, :bookmark)
|
289
297
|
end
|
290
298
|
|
@@ -301,7 +309,7 @@ module Yify
|
|
301
309
|
# @returns Yify::Models::Bookmark
|
302
310
|
|
303
311
|
def delete_movie_bookmark(params)
|
304
|
-
data = self.class.post("/delete_movie_bookmark", { body: params })
|
312
|
+
data = self.class.post("/delete_movie_bookmark", { body: post_params(params) })
|
305
313
|
Yify::Response.new(data, :api_response)
|
306
314
|
end
|
307
315
|
|
@@ -319,7 +327,7 @@ module Yify
|
|
319
327
|
# @returns Yify::Models::ApiResponse
|
320
328
|
|
321
329
|
def make_comment(params)
|
322
|
-
data = self.class.post("/make_comment", { body: params })
|
330
|
+
data = self.class.post("/make_comment", { body: post_params(params) })
|
323
331
|
Yify::Response.new(data, :api_response)
|
324
332
|
end
|
325
333
|
|
@@ -336,7 +344,7 @@ module Yify
|
|
336
344
|
# @returns Yify::Models::ApiResponse
|
337
345
|
|
338
346
|
def like_comment(params)
|
339
|
-
data = self.class.post("/like_comment", { body: params })
|
347
|
+
data = self.class.post("/like_comment", { body: post_params(params) })
|
340
348
|
Yify::Response.new(data, :api_response)
|
341
349
|
end
|
342
350
|
|
@@ -353,7 +361,7 @@ module Yify
|
|
353
361
|
# @returns Yify::Models::ApiResponse
|
354
362
|
|
355
363
|
def report_comment(params)
|
356
|
-
data = self.class.post("/report_comment", { body: params })
|
364
|
+
data = self.class.post("/report_comment", { body: post_params(params) })
|
357
365
|
Yify::Response.new(data, :api_response)
|
358
366
|
end
|
359
367
|
|
@@ -370,7 +378,7 @@ module Yify
|
|
370
378
|
# @returns Yify::Models::ApiResponse
|
371
379
|
|
372
380
|
def delete_comment(params)
|
373
|
-
data = self.class.post("/delete_comment", { body: params })
|
381
|
+
data = self.class.post("/delete_comment", { body: post_params(params) })
|
374
382
|
Yify::Response.new(data, :api_response)
|
375
383
|
end
|
376
384
|
|
@@ -388,7 +396,7 @@ module Yify
|
|
388
396
|
# @returns Yify::Models::ApiResponse
|
389
397
|
|
390
398
|
def make_request(params)
|
391
|
-
data = self.class.post("/make_request", { body: params })
|
399
|
+
data = self.class.post("/make_request", { body: post_params(params) })
|
392
400
|
Yify::Response.new(data, :api_response)
|
393
401
|
end
|
394
402
|
|
data/lib/yify/support/utils.rb
CHANGED
data/lib/yify/version.rb
CHANGED
data/spec/yify_spec.rb
CHANGED
@@ -10,6 +10,16 @@ describe Yify::Client do
|
|
10
10
|
expect(subject.class.base_uri).to eq("http://yts.to/api/v2")
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should set an application_key" do
|
14
|
+
client = Yify::Client.new(ENV["application_key"])
|
15
|
+
expect(client.application_key).to eq(ENV["application_key"])
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should set an application_key from an ENV variable" do
|
19
|
+
client = Yify::Client.new
|
20
|
+
expect(client.application_key).to eq(ENV["application_key"])
|
21
|
+
end
|
22
|
+
|
13
23
|
it "should list movies", :vcr do
|
14
24
|
response = subject.list_movies({ limit: 3 })
|
15
25
|
expect(response.result.count).to eq(3)
|
@@ -98,7 +108,7 @@ describe Yify::Client do
|
|
98
108
|
end
|
99
109
|
|
100
110
|
it "should add a movie bookmark", :vcr do
|
101
|
-
params = {
|
111
|
+
params = { user_key: ENV["user_key"], movie_id: 353 }
|
102
112
|
request = subject.add_movie_bookmark(params)
|
103
113
|
expect(request.response["status_message"]).to eq("Movie has been successfully bookmarked")
|
104
114
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Lunsford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
230
|
version: '0'
|
231
231
|
requirements: []
|
232
232
|
rubyforge_project:
|
233
|
-
rubygems_version: 2.
|
233
|
+
rubygems_version: 2.2.2
|
234
234
|
signing_key:
|
235
235
|
specification_version: 4
|
236
236
|
summary: YIFY Torrents API
|