film_on 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/film_on/models/genre.rb +43 -0
- data/lib/film_on/services/video_on_demand.rb +42 -0
- data/lib/film_on.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e90957e7c38e5ca34508ffaaf3401086d13fd86
|
4
|
+
data.tar.gz: 72c2071448384b697a74d1dfd6655a0ec2e5d280
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1729168b90f1197aa23946b7a9171f994434fe06976c54c5c645c394157710afb61d82e7ac1838ccb289eacd8061eeb38ffc27754e77f74c3e868ebe6598e937
|
7
|
+
data.tar.gz: c9689f75ed3fa79a49db0526c686aedc687abf6865a32e17c301bb1063c351d5d6d30831b5f07bb03cd7799899e41a658f35bdb412988be6b22921dd2f82e678
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module FilmOn
|
2
|
+
|
3
|
+
# Genre is a group of movies bundled together
|
4
|
+
# such as "Sports" or "Horror"
|
5
|
+
# takes a raw hash and converts it into a nice ruby
|
6
|
+
# object
|
7
|
+
|
8
|
+
class Genre
|
9
|
+
|
10
|
+
Image = Struct.new(:type, :width, :height, :url)
|
11
|
+
|
12
|
+
attr_reader :id, :vendorka_id, :name, :slug, :position
|
13
|
+
attr_reader :content_count, :updated_at, :description, :images
|
14
|
+
attr_reader :standard_image, :retina_image
|
15
|
+
|
16
|
+
def initialize(hash)
|
17
|
+
@id = hash["id"]
|
18
|
+
@vendorka_id = hash["vendorka_id"]
|
19
|
+
@name = hash["name"]
|
20
|
+
@slug = hash["slug"]
|
21
|
+
@position = hash["position"]
|
22
|
+
@content_count = hash["content_count"]
|
23
|
+
@updated_at = hash["updated_at"]
|
24
|
+
@description = hash["description"]
|
25
|
+
@images = get_images(hash["images"])
|
26
|
+
end
|
27
|
+
|
28
|
+
def standard_image
|
29
|
+
images.select{|i| i.type == "logo"}.first
|
30
|
+
end
|
31
|
+
|
32
|
+
def retina_image
|
33
|
+
images.select{|i| i.type == "logo-retina"}.first
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_images(imgs)
|
37
|
+
return [] unless imgs.is_a?(Array)
|
38
|
+
imgs.map{|img| Image.new(img["type"], img["width"], img["height"], img["url"]) }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -2,11 +2,45 @@ module FilmOn
|
|
2
2
|
module Services
|
3
3
|
module VideoOnDemand
|
4
4
|
|
5
|
+
# Ref: http://www.filmon.com/page/api-vod
|
6
|
+
|
7
|
+
def genres(opts={})
|
8
|
+
return @genres if @genres && !opts[:json]
|
9
|
+
json = get_vod("genres")
|
10
|
+
if opts[:json]
|
11
|
+
return json
|
12
|
+
end
|
13
|
+
@genres = convert_genres(json)
|
14
|
+
end
|
15
|
+
|
5
16
|
# movies: calls the vod/search and returns
|
6
17
|
# a list of movies filtered by the params
|
7
18
|
# i.e. film_on.movies(genre: "horror") will
|
8
19
|
# return all horror movies
|
9
20
|
#
|
21
|
+
## Params examples:
|
22
|
+
#
|
23
|
+
# term:
|
24
|
+
# Set this to the word or term to search the catalog for. The FilmOn VOD API searches the title and synopses of catalog titles for a match. This parameter is required.
|
25
|
+
#
|
26
|
+
# start_index:
|
27
|
+
# Set this to a zero-based offset into the list that results from the query. By using this with the max_results parameter, you can request successive pages of search results.
|
28
|
+
#
|
29
|
+
# max_results:
|
30
|
+
# Set this to the maximum number of results to return. This number cannot be greater than 100. If you do not specify max_results, the default value is 25.
|
31
|
+
#
|
32
|
+
# parent_id:
|
33
|
+
# search for episodes of specified series.
|
34
|
+
#
|
35
|
+
# order_by:
|
36
|
+
# Order search results by one of following strategies: "relevance" or "date"
|
37
|
+
#
|
38
|
+
# content_type:
|
39
|
+
# Filter and return search results only for specified content_type. Parameter value should be one of : "relevance" or "date"
|
40
|
+
#
|
41
|
+
# genre:
|
42
|
+
# Filter and search for movies only in specified genre. Parameter value should be a slug of corresponding genre, retrieved from /api/vod/genres resource.
|
43
|
+
|
10
44
|
def movies(params={}, opts={})
|
11
45
|
key = Digest::MD5.hexdigest(params.to_s)
|
12
46
|
return @vod_search[key] if @vod_search[key] && !opts[:json]
|
@@ -49,6 +83,14 @@ module FilmOn
|
|
49
83
|
FilmOn::Movie.new(hash)
|
50
84
|
end
|
51
85
|
|
86
|
+
# convert_genres: takes the raw JSON
|
87
|
+
# and converts it into a nice ruby array of objects
|
88
|
+
#
|
89
|
+
def convert_genres(json)
|
90
|
+
hash = JSON.parse(json)["response"]
|
91
|
+
hash.map{|gen| FilmOn::Genre.new(gen)}
|
92
|
+
end
|
93
|
+
|
52
94
|
end
|
53
95
|
end
|
54
96
|
end
|
data/lib/film_on.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: film_on
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Hanscombe
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/film_on.rb
|
116
116
|
- lib/film_on/base.rb
|
117
117
|
- lib/film_on/models/channel.rb
|
118
|
+
- lib/film_on/models/genre.rb
|
118
119
|
- lib/film_on/models/group.rb
|
119
120
|
- lib/film_on/models/movie.rb
|
120
121
|
- lib/film_on/models/programme.rb
|