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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4787ad8b4cebe28bc0697fdd716a4c1a585a12b5
4
- data.tar.gz: dd0e52bf341b6458aebeac666a3a18dd3f983722
3
+ metadata.gz: 0a748636163db9e9fb0332d005515c3af6bd4a86
4
+ data.tar.gz: 21a48ee2990b1dbbe7fbdd6664235eb1b5326a66
5
5
  SHA512:
6
- metadata.gz: ceb65b48a1bf538e31fd72934a794d1ee27f5205a2e77d8f469e16aa70d97e26ad8f06dc74d639cc9ad5c296fe9d04d80a4c1d62ddbb9591dbeab09903df7e09
7
- data.tar.gz: 108a188e016bcaf4e3b42ef0c544c54755629f6c8a506e2b7b6a308890ca558ee809db4aec9337e3dc08a2a6dd1619873078ec0c4b2d123ab8343f2dce0dab28
6
+ metadata.gz: dd525415f8aaa93246da1979c9e66891b291faf79c19f8c8acbe88b3ba367ea32dc819e33e8c7477c38d5b091930d5f17c6d4bec24769a2c5abe897eac6e2eea
7
+ data.tar.gz: ef62a9e866c5e382a81ac62e5309471d569872aeb27a5f44e8a6d3fdc56ae7c05ea7437606e978a9270c7387f2b468ab48236381107e6f71f213c323768a22f0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
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
- # movies: calls the vod/search and returns
17
- # a list of movies filtered by the params
18
- # i.e. film_on.movies(genre: "horror") will
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 movies(params={}, opts={})
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] = convert_movies(json)
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
- # convert_movies: takes the raw JSON
67
- # and coverts it into a nice array of ruby objects
68
- # normal for use after storing the JSON in
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 convert_movies(json)
72
- hash = JSON.parse(json)["response"]
73
- hash.map{|movie| FilmOn::Movie.new(movie) }
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.14
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-20 00:00:00.000000000 Z
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler