film_on 0.0.14 → 0.0.15
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/services/video_on_demand.rb +27 -13
- 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: 0a748636163db9e9fb0332d005515c3af6bd4a86
|
4
|
+
data.tar.gz: 21a48ee2990b1dbbe7fbdd6664235eb1b5326a66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd525415f8aaa93246da1979c9e66891b291faf79c19f8c8acbe88b3ba367ea32dc819e33e8c7477c38d5b091930d5f17c6d4bec24769a2c5abe897eac6e2eea
|
7
|
+
data.tar.gz: ef62a9e866c5e382a81ac62e5309471d569872aeb27a5f44e8a6d3fdc56ae7c05ea7437606e978a9270c7387f2b468ab48236381107e6f71f213c323768a22f0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
@@ -2,6 +2,14 @@ module FilmOn
|
|
2
2
|
module Services
|
3
3
|
module VideoOnDemand
|
4
4
|
|
5
|
+
# VodSearchResult: Struct to handle the response from the search, which includes
|
6
|
+
# an array of movies, as well as the actual number returned (total)
|
7
|
+
# and the overall total for the seach result (total_found)
|
8
|
+
# to get the array of movies we have to do
|
9
|
+
# film_on.vod_search.movies
|
10
|
+
#
|
11
|
+
VodSearchResult = Struct.new(:total, :total_found, :movies)
|
12
|
+
|
5
13
|
# Ref: http://www.filmon.com/page/api-vod
|
6
14
|
|
7
15
|
def genres(opts={})
|
@@ -13,10 +21,12 @@ module FilmOn
|
|
13
21
|
@genres = convert_genres(json)
|
14
22
|
end
|
15
23
|
|
16
|
-
#
|
17
|
-
# a list of movies filtered by the params
|
18
|
-
# i.e.
|
19
|
-
# return all horror movies
|
24
|
+
# vod_search: calls the vod/search and returns
|
25
|
+
# a list of movies filtered by the params and the number returned (total) and the total number for the search (total_found)
|
26
|
+
# i.e.
|
27
|
+
# film_on.vod_search(genre: "horror").movies => will return all horror movies
|
28
|
+
# film_on.vod_search(genre: "horror").total => will return the number of movies return from the feed
|
29
|
+
# film_on.vod_search(genre: "horror").total_found => will return the total number of movies available with the given params (useful for pagination)
|
20
30
|
#
|
21
31
|
## Params examples:
|
22
32
|
#
|
@@ -41,14 +51,14 @@ module FilmOn
|
|
41
51
|
# genre:
|
42
52
|
# 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
53
|
|
44
|
-
def
|
54
|
+
def vod_search(params={}, opts={})
|
45
55
|
key = Digest::MD5.hexdigest(params.to_s)
|
46
56
|
return @vod_search[key] if @vod_search[key] && !opts[:json]
|
47
57
|
json = get_vod("search", params)
|
48
58
|
if opts[:json]
|
49
59
|
return json
|
50
60
|
end
|
51
|
-
@vod_search[key] =
|
61
|
+
@vod_search[key] = convert_vod_search(json)
|
52
62
|
end
|
53
63
|
|
54
64
|
# movie: retrieve a specific movie with a given id
|
@@ -63,14 +73,18 @@ module FilmOn
|
|
63
73
|
@movie[id] = convert_movie(json)
|
64
74
|
end
|
65
75
|
|
66
|
-
#
|
67
|
-
# and coverts it into
|
68
|
-
#
|
69
|
-
# a caching mechanism
|
76
|
+
# convert_vod_search: takes the raw JSON
|
77
|
+
# and coverts it into an object, which includes
|
78
|
+
# the total, total_found and a nice array of movies as ruby objects
|
79
|
+
# normally for use after storing the JSON in a caching mechanism
|
70
80
|
#
|
71
|
-
def
|
72
|
-
hash = JSON.parse(json)
|
73
|
-
|
81
|
+
def convert_vod_search(json)
|
82
|
+
hash = JSON.parse(json)
|
83
|
+
VodSearchResult.new(
|
84
|
+
hash["total"],
|
85
|
+
hash["total_found"],
|
86
|
+
hash["response"].map{|movie| FilmOn::Movie.new(movie) }
|
87
|
+
)
|
74
88
|
end
|
75
89
|
|
76
90
|
# convert_movie: takes the raw JSON
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Hanscombe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|