film_on 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11cf93dc5732caafd770dd3dcfdeccd26dc16414
4
+ data.tar.gz: 3c68bf0fb971ea890447387d60fbf529cbb1060a
5
+ SHA512:
6
+ metadata.gz: dcad05bcf733fc934b3cedbcad2a55254dc6c7c59cc035d5452a449aca5b46348938e2e3894751e94acb114818f6b1d10233571fffc0b11bdef02fb7b6512951
7
+ data.tar.gz: 6e14d4ca8071fdc07c3bcba3cdfa0312676d5e1589ac94f21bc7c8a589da4f2504682cdd8cf2d9747a6e6c041cba8ff40254ddcdc348f553c9065588f129e91c
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
11
+ .ruby-version
12
+ film_on*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in film_on.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Stuart Hanscombe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # FilmOn
2
+
3
+ A Ruby wrapper for the FilmOn API: http://www.filmon.com/page/api
4
+
5
+ This is currently at version 0.0.1 and only handles channels, channel
6
+ and groups methods
7
+
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'film_on'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install film_on
24
+
25
+ ## Usage
26
+
27
+ Refer to FilmOn Api (http://www.filmon.com/page/api):
28
+
29
+ Obtain your app_key and app_secret from FilmOn
30
+
31
+ app_key = "foo"
32
+ app_secret = "bar"
33
+
34
+ film_on = FilmOn::Base.new(app_key, app_secret)
35
+
36
+ film_on.channels => returns list of all channels as ruby objects
37
+ flim_on.groups => returns list of all groups as ruby objects
38
+ film_on.channel(id) => returns info for given channel as a ruby object
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/film_on.
49
+
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
54
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "film_on"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/film_on.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'film_on/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "film_on"
8
+ spec.version = FilmOn::VERSION
9
+ spec.authors = ["Stuart Hanscombe"]
10
+ spec.email = ["hanscs1969@yahoo.co.uk"]
11
+
12
+ spec.summary = %q{Ruby wrapper for the FilmOn API}
13
+ spec.description = %q{Ruby wrapper to initialize connection and call the Film On API services}
14
+ spec.homepage = "https://github.com/thelazycamel/film_on"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "webmock"
26
+ spec.add_development_dependency "rake_roll"
27
+ spec.add_development_dependency "pry"
28
+ spec.add_runtime_dependency "httparty"
29
+ end
@@ -0,0 +1,55 @@
1
+ require "HTTParty"
2
+ require_relative "services"
3
+
4
+ module FilmOn
5
+
6
+ class Base
7
+
8
+ include Services
9
+
10
+ URI = "www.filmon.com/tv/api/"
11
+
12
+ attr_reader :app_key, :app_secret, :session_key
13
+
14
+ def initialize(app_key, app_secret)
15
+ @app_key = app_key
16
+ @app_secret = app_secret
17
+ @channel = {}
18
+ init_request
19
+ end
20
+
21
+ def init_request
22
+ response = get("init")
23
+ @session_key = response["session_key"]
24
+ self
25
+ end
26
+
27
+ private
28
+
29
+ def post(service, query={}, protocol="http://")
30
+ query["format"] = "json"
31
+ query["session_key"] = @session_key unless service == "init"
32
+ full_service_url = "#{protocol}#{URI}#{service}"
33
+ response = HTTParty.post(full_service_url, {body: query, headers: {'Content-Type' => 'application/json'}})
34
+ if response && response.code == 200
35
+ return JSON.parse(response.body)
36
+ else
37
+ response.response
38
+ end
39
+ end
40
+
41
+ def get(service, query={}, protocol="http://")
42
+ query["format"] = "json"
43
+ query["session_key"] = @session_key unless service == "init"
44
+ full_service_url = "#{protocol}#{URI}#{service}?#{query.map{|k,v| "#{k}=#{v}"}.join("&")}"
45
+ response = HTTParty.get(full_service_url)
46
+ if response && response.code == 200
47
+ return JSON.parse(response.body)
48
+ else
49
+ response.response
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,64 @@
1
+ module FilmOn
2
+
3
+ # FilmOn::Channel
4
+ # Channel can have either a basic set of data or a more verbose set
5
+ # depending on whether it is called as part of a channels list or
6
+ # as in individual call
7
+
8
+ class Channel
9
+
10
+ attr_reader :hash, :id, :title, :alias, :logo, :big_logo, :content_rating, :adult_content
11
+ attr_reader :group, :group_id, :is_free, :is_free_sd_mode, :type, :has_tvguide, :seekable
12
+ attr_reader :serverside_record, :extra_big_logo, :upnp_enabled, :is_favorite
13
+ #extended
14
+ attr_reader :is_adult, :is_interactive, :is_vod, :is_vox, :chat_keyword, :recordable, :programmes
15
+ attr_reader :preload_message, :preload_timeout, :is_local, :preload_intro, :images, :schedule, :tvguide
16
+
17
+ def initialize(hash)
18
+ @hash = hash
19
+ @id = hash["id"]
20
+ @title = hash["title"]
21
+ @alias = hash["alias"]
22
+ @logo = hash["logo"]
23
+ @big_logo = hash["big_logo"]
24
+ @content_rating = hash["content_rating"]
25
+ @adult_content = hash["adult_content"]
26
+ @group = hash["group"]
27
+ @group_id = hash["group_id"]
28
+ @is_free = hash["is_free"]
29
+ @is_free_sd_mode = hash["is_free_sd_mode"]
30
+ @type = hash["type"]
31
+ @has_tvguide = hash["has_tvguide"]
32
+ @seekable = hash["seekable"]
33
+ @serverside_record = hash["serverside_record"]
34
+ @extra_big_logo = hash["extra_big_logo"]
35
+ @upnp_enabled = hash["upnp_enabled"]
36
+ @is_favorite = hash["is_favorite"]
37
+ #extended
38
+ @is_adult = hash["is_adult"]
39
+ @is_interactive = hash["is_interactive"]
40
+ @is_vod = hash["is_vod"]
41
+ @is_vox = hash["is_vox"]
42
+ @chat_keyword = hash["chat_keyword"]
43
+ @recordable = hash["recordable"]
44
+ @preload_message = hash["preload_message"]
45
+ @preload_timeout = hash["preload_timeout"]
46
+ @is_local = hash["is_local"]
47
+ @preload_intro = hash["preload_intro"]
48
+ @images = hash["images"]
49
+ @schedule = hash["schedule"]
50
+ @tvguide = get_tvguide(hash["tvguide"])
51
+ end
52
+
53
+ def get_tvguide(guide)
54
+ return [] unless guide
55
+ guide.map{|gu| FilmOn::Programme.new(gu) }
56
+ end
57
+
58
+ def programmes
59
+ @tvguide
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,28 @@
1
+ module FilmOn
2
+
3
+ class Group
4
+
5
+ attr_reader :hash
6
+ attr_reader :group_id, :id, :title, :group, :original_name, :alias, :description
7
+ attr_reader :weight, :logo_uri, :logo_148x148_uri, :logos, :channels, :channels_count
8
+
9
+ def initialize(hash)
10
+ @hash = hash
11
+ @group_id = hash["group_id"]
12
+ @id = hash["id"]
13
+ @title = hash["title"]
14
+ @group = hash["group"]
15
+ @original_name = hash["original_name"]
16
+ @alias = hash["alias"]
17
+ @description = hash["description"]
18
+ @weight = hash["weight"]
19
+ @logo_uri = hash["logo_uri"]
20
+ @logo_148x148_uri = hash["logo_148x148_uri"]
21
+ @logos = hash["logos"]
22
+ @channels = hash["channels"]
23
+ @channels_count = hash["channels_count"]
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,39 @@
1
+ module FilmOn
2
+
3
+ class Programme
4
+
5
+ Image = Struct.new(:id, :type, :size, :width, :height, :url, :copyright)
6
+
7
+ attr_reader :hash
8
+ attr_reader :programme, :startdatetime, :enddatetime, :duration, :length, :programme_description, :programme_name, :allow_dvr
9
+ attr_reader :allow_reminder, :channel_id, :images, :provider, :vendor_id, :series_number, :episode_number, :series_id, :is_series
10
+
11
+ def initialize(hash)
12
+ @hash = hash
13
+ @programme = hash["programme"]
14
+ @startdatetime = hash["startdatetime"]
15
+ @enddatetime = hash["enddatetime"]
16
+ @duration = hash["duration"]
17
+ @length = hash["length"]
18
+ @programme_description = hash["programme_description"]
19
+ @programme_name = hash["programme_name"]
20
+ @allow_dvr = hash["allow_dvr"]
21
+ @allow_reminder = hash["allow_reminder"]
22
+ @channel_id = hash["channel_id"]
23
+ @images = get_images(hash["images"])
24
+ @provider = hash["provider"]
25
+ @vendor_id = hash["vendor_id"]
26
+ @series_number = hash["seriesNumber"]
27
+ @episode_number = hash["episodeNumber"]
28
+ @series_id = hash["seriesId"]
29
+ @is_series = hash["isSeries"]
30
+ end
31
+
32
+ def get_images(imgs)
33
+ return [] unless imgs.is_a?(Array)
34
+ imgs.map{|img| Image.new(img["id"], img["type"], img["size"], img["width"], img["height"], img["url"], img["copyright"]) }
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,25 @@
1
+ module FilmOn
2
+
3
+ module Services
4
+
5
+ def channel(id)
6
+ return @channel[id] if @channel[id]
7
+ hash = get("channel/#{id}")
8
+ @channel[id] = FilmOn::Channel.new(hash)
9
+ end
10
+
11
+ def channels
12
+ return @channels if @channels
13
+ hash = get("channels")
14
+ @channels = hash.map{|ch| FilmOn::Channel.new(ch)}
15
+ end
16
+
17
+ def groups
18
+ return @groups if @groups
19
+ hash = get("groups")
20
+ @groups = hash.map{|gr| FilmOn::Group.new(gr)}
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,3 @@
1
+ module FilmOn
2
+ VERSION = File.read(File.dirname(__FILE__) + "/../../VERSION").strip
3
+ end
data/lib/film_on.rb ADDED
@@ -0,0 +1,5 @@
1
+ Dir[File.dirname(__FILE__) + "/film_on/**/*.rb"].each {|file| require file }
2
+
3
+ module FilmOn
4
+
5
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: film_on
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stuart Hanscombe
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake_roll
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: httparty
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Ruby wrapper to initialize connection and call the Film On API services
112
+ email:
113
+ - hanscs1969@yahoo.co.uk
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - VERSION
126
+ - bin/console
127
+ - bin/setup
128
+ - film_on.gemspec
129
+ - lib/film_on.rb
130
+ - lib/film_on/base.rb
131
+ - lib/film_on/models/channel.rb
132
+ - lib/film_on/models/group.rb
133
+ - lib/film_on/models/programme.rb
134
+ - lib/film_on/services.rb
135
+ - lib/film_on/version.rb
136
+ homepage: https://github.com/thelazycamel/film_on
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.4.5.1
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Ruby wrapper for the FilmOn API
160
+ test_files: []