netflix_roulette 0.0.0 → 0.0.1
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 +8 -8
- data/lib/netflix_roulette.rb +74 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzU1ZjI0YTZlNDliMGNhNWEyNjk5MTM5OWRmNzZmYzdhMGM0MzljOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzY2OTNiZmIyYjlmODJjNjBkMmM1Yjk2ZGMyMmZlZTgwZjA4OWEzNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDQyYjlkYTM3MWNhZmI0NTlmMWFlOThhMzY4OTM1NjdlZDE0MDUyZTc0YzE2
|
10
|
+
ZWVhYTIxY2E4MTMzZTYxZWI5OGIzYWVhOGVjMzk0Y2IyNzBiOTk0MTkzNjRi
|
11
|
+
MDllMmUwYTVjN2I1NWZkYWI3YWQzNjZkYWU5Yjk2MmZjNzYxMTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGVjNGNlMmRmZGFmNGIxZWE2MTliMDVjOGZmM2FhMzMzMmI5NWZkYjllYzQ5
|
14
|
+
MjliODdhYjg2ZDRkNGVlYjIyZDFkMjVhZTE2OTg0ODJiYTE5NmEyNjRhZmFm
|
15
|
+
YzYzNzdlY2RjMzAyZjM5NDhlOTc4MTdmYjIzNmI4ODkwZTVjYWE=
|
data/lib/netflix_roulette.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
class NetflixRoulette
|
5
|
+
class << self
|
6
|
+
{
|
7
|
+
get_media_rating: "rating",
|
8
|
+
get_media_poster: "poster",
|
9
|
+
get_media_type: "mediatype",
|
10
|
+
get_media_release_year: "release_year",
|
11
|
+
get_media_cast: "show_cast",
|
12
|
+
get_media_category: "category",
|
13
|
+
get_media_summary: "summary",
|
14
|
+
get_media_director: "director",
|
15
|
+
get_netflix_id: "show_id"
|
16
|
+
}.each_pair do |method_name, key|
|
17
|
+
define_method method_name do |title, year = 0|
|
18
|
+
client(title, year).fetch[key] || "Unable to locate data"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_all_data(title, year = 0)
|
23
|
+
client(title, year).fetch
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_version
|
27
|
+
Client::API_VERSION
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def client(title, year)
|
33
|
+
Client.new(title, year)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Client
|
38
|
+
API_URL = URI("http://netflixroulette.net/api/api.php")
|
39
|
+
API_VERSION = "5.0"
|
40
|
+
|
41
|
+
attr_accessor :title, :year
|
42
|
+
|
43
|
+
def initialize(title, year = 0)
|
44
|
+
@title = title
|
45
|
+
@year = year
|
46
|
+
end
|
47
|
+
|
48
|
+
def version
|
49
|
+
API_VERSION
|
50
|
+
end
|
51
|
+
|
52
|
+
def fetch
|
53
|
+
uri = API_URL
|
54
|
+
uri.query = URI.encode_www_form({ title: title, year: year })
|
55
|
+
response = Net::HTTP.get_response uri
|
56
|
+
|
57
|
+
result = JSON.parse response.body
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# nr = NetflixRoulette::Client.new "Breaking Bad"
|
63
|
+
# puts nr.fetch
|
64
|
+
#
|
65
|
+
# puts NetflixRoulette.get_media_rating("Breaking Bad")
|
66
|
+
# puts NetflixRoulette.get_media_poster("Breaking Bad")
|
67
|
+
# puts NetflixRoulette.get_media_type("Breaking Bad")
|
68
|
+
# puts NetflixRoulette.get_media_release_year("Breaking Bad")
|
69
|
+
# puts NetflixRoulette.get_media_cast("Breaking Bad")
|
70
|
+
# puts NetflixRoulette.get_media_category("Breaking Bad")
|
71
|
+
# puts NetflixRoulette.get_media_summary("Breaking Bad")
|
72
|
+
# puts NetflixRoulette.get_media_director("Breaking Bad")
|
73
|
+
# puts NetflixRoulette.get_netflix_id("Breaking Bad")
|
74
|
+
# puts NetflixRoulette.get_all_data("Breaking Bad")
|