canistreamit 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +103 -35
- data/lib/canistreamit/client.rb +47 -8
- data/lib/canistreamit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2f20944e9342cf9b1b058624c112561b85a34bc
|
4
|
+
data.tar.gz: 97b18d5a4947a699b90339ce60890a91dff95568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c2a14a9a3ba67ee0363ad3bb5bcca93bcc99ebbe2f2059ad05bf03b43b918c0c978646b11c729e5b646ca6a4bbcaea68609515814e1ae17ca3fb56ad873a94f
|
7
|
+
data.tar.gz: 5f146fb0df6a7af94053fee0dc27676525e724052e7931b624e725e1a17be122db1de7856ec35d4a94d5bbfd9ebea1d7aa4966de060be9899d3f4c41df87fa54
|
data/README.md
CHANGED
@@ -24,13 +24,13 @@ $ gem install canistreamit
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
Create a new client
|
27
|
+
### Create a new client
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
client = Canistreamit::Client.new
|
31
31
|
```
|
32
32
|
|
33
|
-
Search for movies by title
|
33
|
+
### Search for movies by title
|
34
34
|
|
35
35
|
```ruby
|
36
36
|
client.search("Everything is Illuminated")
|
@@ -49,49 +49,117 @@ client.search("Everything is Illuminated")
|
|
49
49
|
"http://www.canistream.it/search/movie/4ebdd5f9f5f807716100001b/everything-is-illuminated"}}]
|
50
50
|
```
|
51
51
|
|
52
|
-
Query canistream.it by movie id and media type
|
52
|
+
### Query canistream.it by movie id and media type
|
53
53
|
|
54
54
|
```ruby
|
55
|
-
client.query("4ebdd5f9f5f807716100001b", "rental")
|
56
|
-
=> {"
|
57
|
-
{"
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
55
|
+
client.query("4ebdd5f9f5f807716100001b", ["rental", "streaming"])
|
56
|
+
=> {"rental"=>
|
57
|
+
{"apple_itunes_rental"=>
|
58
|
+
{"url"=>"http://www.canistream.it/link/go/4f33decdf5f8073e10000025",
|
59
|
+
"price"=>3.99,
|
60
|
+
"external_id"=>293314469,
|
61
|
+
"date_checked"=>1391095519,
|
62
|
+
"direct_url"=>
|
63
|
+
"http://click.linksynergy.com/fs-bin/click?id=g0LjNrUM/ms&subid=&offerid=146261.1&type=10&tmpid=3909&RD_PARM1=https%3A%2F%2Fitunes.apple.com%2Fus%2Fmovie%2Feverything-is-illuminated%2Fid293314469%3Fuo%3D4",
|
64
|
+
"time"=>0,
|
65
|
+
"friendlyName"=>"Apple iTunes Rental",
|
66
|
+
"cache"=>true},
|
67
|
+
"android_rental"=>
|
68
|
+
{"url"=>"http://www.canistream.it/link/go/4f47c662f5f8076d43000001",
|
69
|
+
"price"=>1.99,
|
70
|
+
"external_id"=>"movie-KdHNp9FPGG8",
|
71
|
+
"date_checked"=>1391095520,
|
72
|
+
"direct_url"=>
|
73
|
+
"https://play.google.com/store/movies/details/Everything_is_Illuminated?id=KdHNp9FPGG8",
|
74
|
+
"time"=>0,
|
75
|
+
"friendlyName"=>"Google Play Rental",
|
76
|
+
"cache"=>true}},
|
77
|
+
"streaming"=>
|
78
|
+
{"hitbliss_streaming"=>
|
79
|
+
{"url"=>"http://www.canistream.it/link/go/5297e955f5f807dd7fb627bf",
|
80
|
+
"price"=>0,
|
81
|
+
"external_id"=>
|
82
|
+
"http://www.hitbliss.com/movies/Everything-Is-Illuminated.html?utm_source=canistreamit&utm_medium=feed&utm_campaign=tv-movies",
|
83
|
+
"date_checked"=>1391095487,
|
84
|
+
"direct_url"=>
|
85
|
+
"http://www.hitbliss.com/movies/Everything-Is-Illuminated.html?utm_source=canistreamit&utm_medium=feed&utm_campaign=tv-movies",
|
86
|
+
"time"=>0,
|
87
|
+
"friendlyName"=>"Hitbliss Streaming",
|
88
|
+
"cache"=>true}}}
|
86
89
|
```
|
87
90
|
|
88
91
|
Available media types:
|
89
|
-
- streaming
|
92
|
+
- streaming (default)
|
90
93
|
- rental
|
91
94
|
- purchase
|
92
95
|
- dvd
|
93
96
|
- xfinity
|
94
97
|
|
98
|
+
Because each media type will result in one slow request to canistream.it API,
|
99
|
+
avoid including more types than you care for.
|
100
|
+
|
101
|
+
### Query canistream.it for all search results at once
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
client.search_and_query("die hard", ["rental", "streaming"])
|
105
|
+
=> [{"movie"=>
|
106
|
+
{"actors"=>"Bruce Willis, Justin Long, Timothy Olyphant",
|
107
|
+
"year"=>2007,
|
108
|
+
"description"=>"",
|
109
|
+
"title"=>"Live Free or Die Hard",
|
110
|
+
"image"=>"http://content8.flixster.com/movie/10/93/34/10933482_det.jpg",
|
111
|
+
"rating"=>4.05,
|
112
|
+
"_id"=>"4e65e608f5f8073663000000",
|
113
|
+
"links"=>
|
114
|
+
{"imdb"=>"http://www.imdb.com/title/tt0337978/",
|
115
|
+
"rottentomatoes"=>
|
116
|
+
"http://www.rottentomatoes.com/m/live_free_or_die_hard/",
|
117
|
+
"shortUrl"=>
|
118
|
+
"http://www.canistream.it/search/movie/4e65e608f5f8073663000000/live-free-or-die-hard"}},
|
119
|
+
"availability"=>
|
120
|
+
{"rental"=>
|
121
|
+
{"apple_itunes_rental"=>
|
122
|
+
{"url"=>"http://www.canistream.it/link/go/4f1ba3dcf5f807036000006f",
|
123
|
+
"price"=>2.99,
|
124
|
+
"external_id"=>279609666,
|
125
|
+
"date_checked"=>1391065570,
|
126
|
+
"direct_url"=>
|
127
|
+
"http://click.linksynergy.com/fs-bin/click?id=g0LjNrUM/ms&subid=&offerid=146261.1&type=10&tmpid=3909&RD_PARM1=https%3A%2F%2Fitunes.apple.com%2Fus%2Fmovie%2Flive-free-or-die-hard-unrated%2Fid279609666%3Fuo%3D4",
|
128
|
+
"time"=>0,
|
129
|
+
"friendlyName"=>"Apple iTunes Rental",
|
130
|
+
"cache"=>true},
|
131
|
+
"youtube_rental"=>
|
132
|
+
{"url"=>"http://www.canistream.it/link/go/5096bb04f5f807d313000008",
|
133
|
+
"price"=>"2.99",
|
134
|
+
"external_id"=>"WXPPz8-6IOk",
|
135
|
+
"date_checked"=>1391065568,
|
136
|
+
"direct_url"=>
|
137
|
+
"http://www.youtube.com/watch?v=WXPPz8-6IOk&feature=youtube_gdata_player",
|
138
|
+
"time"=>0,
|
139
|
+
"friendlyName"=>"Youtube Rental",
|
140
|
+
"cache"=>true}},
|
141
|
+
"streaming"=>
|
142
|
+
{"hitbliss_streaming"=>
|
143
|
+
{"url"=>"http://www.canistream.it/link/go/528f9102f5f807fb39579006",
|
144
|
+
"price"=>0,
|
145
|
+
"external_id"=>
|
146
|
+
"http://www.hitbliss.com/movies/Live-Free-or-Die-Hard.html?utm_source=canistreamit&utm_medium=feed&utm_campaign=tv-movies",
|
147
|
+
"date_checked"=>1391065571,
|
148
|
+
"direct_url"=>
|
149
|
+
"http://www.hitbliss.com/movies/Live-Free-or-Die-Hard.html?utm_source=canistreamit&utm_medium=feed&utm_campaign=tv-movies",
|
150
|
+
"time"=>0,
|
151
|
+
"friendlyName"=>"Hitbliss Streaming",
|
152
|
+
"cache"=>true}}}}]
|
153
|
+
```
|
154
|
+
|
155
|
+
Because this is pretty heavy on canistream.it API,
|
156
|
+
`search_and_query` only queries for the first search result by default.
|
157
|
+
You can set your own limit with a third parameter, but be responsible:
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
client.search_and_query("die hard", "rental", 5)
|
161
|
+
```
|
162
|
+
|
95
163
|
## Contributing
|
96
164
|
|
97
165
|
1. Fork it (http://github.com/KevinBongart/canistreamit/fork)
|
data/lib/canistreamit/client.rb
CHANGED
@@ -9,7 +9,9 @@ module Canistreamit
|
|
9
9
|
|
10
10
|
base_uri Configuration::DEFAULT_ENDPOINT
|
11
11
|
|
12
|
-
|
12
|
+
VALID_MEDIA_TYPES = ["streaming", "rental", "purchase", "dvd", "xfinity"].freeze
|
13
|
+
|
14
|
+
def initialize(options = {})
|
13
15
|
# Merge the config values from the module and those passed
|
14
16
|
# to the client.
|
15
17
|
merged_options = Canistreamit.options.merge(options)
|
@@ -26,14 +28,51 @@ module Canistreamit
|
|
26
28
|
response.parsed_response
|
27
29
|
end
|
28
30
|
|
29
|
-
def query(movie_id,
|
30
|
-
|
31
|
-
|
32
|
-
attributes: '1',
|
33
|
-
mediaType: media_type
|
34
|
-
}
|
31
|
+
def query(movie_id, media_types = "streaming")
|
32
|
+
media_types = array_of_unique_elements(media_types)
|
33
|
+
return unless valid_media_types?(media_types)
|
35
34
|
|
36
|
-
|
35
|
+
result = {}
|
36
|
+
|
37
|
+
media_types.each do |media_type|
|
38
|
+
response = self.class.get "/query", query: {
|
39
|
+
movieId: movie_id,
|
40
|
+
attributes: '1',
|
41
|
+
mediaType: media_type
|
42
|
+
}
|
43
|
+
|
44
|
+
result[media_type] = response.parsed_response
|
45
|
+
end
|
46
|
+
|
47
|
+
result
|
48
|
+
end
|
49
|
+
|
50
|
+
def search_and_query(movie_name, media_types = "streaming", limit = 1)
|
51
|
+
media_types = array_of_unique_elements(media_types)
|
52
|
+
return unless valid_media_types?(media_types)
|
53
|
+
|
54
|
+
response = search(movie_name)
|
55
|
+
|
56
|
+
if response.any?
|
57
|
+
response.first(limit).map do |movie|
|
58
|
+
{
|
59
|
+
"movie" => movie,
|
60
|
+
"availability" => query(movie["_id"], media_types)
|
61
|
+
}
|
62
|
+
end
|
63
|
+
else
|
64
|
+
response
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def array_of_unique_elements(array_or_element)
|
71
|
+
Array(array_or_element).uniq
|
72
|
+
end
|
73
|
+
|
74
|
+
def valid_media_types?(media_types)
|
75
|
+
(media_types - VALID_MEDIA_TYPES).empty?
|
37
76
|
end
|
38
77
|
end
|
39
78
|
end
|
data/lib/canistreamit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canistreamit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Bongart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|