beamly 0.0.2.beta
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 +7 -0
- data/Readme.md +58 -0
- data/beamly.gemspec +24 -0
- data/lib/beamly/buzz.rb +24 -0
- data/lib/beamly/client.rb +33 -0
- data/lib/beamly/configuration.rb +15 -0
- data/lib/beamly/epg.rb +40 -0
- data/lib/beamly/error.rb +13 -0
- data/lib/beamly/version.rb +7 -0
- data/lib/beamly.rb +40 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5e5be7fcfa5184550e85f895e2f9f9a25c3da662
|
4
|
+
data.tar.gz: 1a8937e1794f6efdcfcb2ecf31475d7027cef79d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 04bd6989e0522deefdddb7e1160f48735a3cd170cc983d3be85b97ca4a8fe3b24ee140255e180cedcb6c95821f5aa67b701c2f1464894e3dfda1f482474ed5f2
|
7
|
+
data.tar.gz: 243092e5f751264b24d179c131e44cc8f0b6dcfba55c44376202090775a916ea6e9b64f4442660b3fce8f5f74a2c32694c700c4558718e6a95d7828320d87ff4
|
data/Readme.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Beamly Gem
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/beamly)
|
4
|
+
|
5
|
+
Create an account on the beamly developers website to get your api keys.
|
6
|
+
|
7
|
+
https://develop.beamly.com/admin/applications
|
8
|
+
|
9
|
+
## Still in early development
|
10
|
+
|
11
|
+
This gem is still in development and will most likely change dramatically. Keep this in mind if you plan to use this in a production environment as its not recommended.
|
12
|
+
|
13
|
+
The gem is only tested against the AU region currently.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add the following to your `Gemfile`:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem "beamly"
|
21
|
+
```
|
22
|
+
|
23
|
+
Add a file `config/initializers/beamly.rb` containing:
|
24
|
+
|
25
|
+
```
|
26
|
+
Beamly.configure do |config|
|
27
|
+
config.id = 'akdwad'
|
28
|
+
config.key = '24144de132cb2d622bzxz60a90ggasffcc6c5c'
|
29
|
+
config.region = 'AU'
|
30
|
+
end
|
31
|
+
```
|
32
|
+
At the moment you should include this file in your app.
|
33
|
+
|
34
|
+
## Methods
|
35
|
+
|
36
|
+
Here are the methods supported so far and a quick description.
|
37
|
+
|
38
|
+
``epg = Beamly::Epg.new``
|
39
|
+
|
40
|
+
``epg.regions`` returns an array of all of the regions.
|
41
|
+
|
42
|
+
``epg.providers`` returns an array of all of the regions.
|
43
|
+
|
44
|
+
``epg.catalogues(region, provider)`` returns an array of all of the catalogues. Provide a region id and provider id.
|
45
|
+
|
46
|
+
``epg.epg(id)`` returns an array of the epg. Id is from the catalogues reguest.
|
47
|
+
|
48
|
+
``epg.schedule(id,date)`` returns an array of the schedules. Provide a service id from the epg request and a date in the format YYYY/MM/DD
|
49
|
+
|
50
|
+
``epg.broadcast_event(id)`` returns an hash of a broadcast event. Provide an id from the schedule request
|
51
|
+
|
52
|
+
``epg.episode(id)`` returns an hash of a episode event. Provide an id from the schedule request
|
53
|
+
|
54
|
+
## Tests
|
55
|
+
|
56
|
+
Include your api id and key as environment variables when running the tests
|
57
|
+
|
58
|
+
``BEAMLY_TEST_ID=xxx BEAMLY_TEST_KEY=xxx bundle exec rspec``
|
data/beamly.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'beamly/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.add_development_dependency 'bundler', '~> 1.0'
|
8
|
+
spec.add_dependency "curb"
|
9
|
+
spec.add_dependency "hashie"
|
10
|
+
spec.add_development_dependency "rake"
|
11
|
+
spec.authors = ["Kieran Anddrews"]
|
12
|
+
spec.description = %q{Simple wrapper for the Beamly API}
|
13
|
+
spec.email = ['hiddentiger@gmail.com']
|
14
|
+
spec.files = %w(Readme.md beamly.gemspec)
|
15
|
+
spec.files += Dir.glob("lib/**/*.rb")
|
16
|
+
spec.homepage = 'https://github.com/TigerWolf/beamly'
|
17
|
+
spec.licenses = ['MIT']
|
18
|
+
spec.name = 'beamly'
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
spec.required_ruby_version = '>= 1.9.2'
|
21
|
+
spec.required_rubygems_version = '>= 1.3.5'
|
22
|
+
spec.summary = "Ruby toolkit for working with the Beamly API"
|
23
|
+
spec.version = Beamly::VERSION.dup
|
24
|
+
end
|
data/lib/beamly/buzz.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Beamly
|
2
|
+
class Buzz
|
3
|
+
|
4
|
+
def prefix_url
|
5
|
+
"/buzz/1/"
|
6
|
+
end
|
7
|
+
|
8
|
+
include Beamly::Client
|
9
|
+
|
10
|
+
def episode(id)
|
11
|
+
get("fts/#{Beamly.configuration.region.downcase}/episode/#{id}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def current(macro_region)
|
15
|
+
get("prevnownext?tvc=#{Beamly.configuration.region.downcase}¯o-region=#{macro_region}")
|
16
|
+
end
|
17
|
+
|
18
|
+
# def broadcast(broadcast_events)
|
19
|
+
# get("buzz?tvc=#{Beamly.configuration.region.downcase}&broadcast_events=#{broadcast_events.join(',')}")
|
20
|
+
# end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Beamly
|
2
|
+
module Client
|
3
|
+
|
4
|
+
def get(url)
|
5
|
+
response = Curl.get(Beamly.base_uri + self.prefix_url + url) do |http|
|
6
|
+
http.headers['zeebox-app-id'] = Beamly.configuration.id
|
7
|
+
http.headers['zeebox-app-key'] = Beamly.configuration.key
|
8
|
+
http.headers["Accept-Encoding"] = "gzip,deflate"
|
9
|
+
http.follow_location = true
|
10
|
+
end
|
11
|
+
begin
|
12
|
+
gz = Zlib::GzipReader.new(StringIO.new(response.body_str))
|
13
|
+
json = gz.read
|
14
|
+
rescue Zlib::GzipFile::Error
|
15
|
+
json = response.body_str
|
16
|
+
end
|
17
|
+
begin
|
18
|
+
result = JSON.parse json
|
19
|
+
rescue JSON::ParserError
|
20
|
+
if response.response_code == 404
|
21
|
+
raise Beamly::NotFound
|
22
|
+
else
|
23
|
+
result = json
|
24
|
+
end
|
25
|
+
end
|
26
|
+
if result.is_a? Array
|
27
|
+
result.collect! { |x| x.is_a?(Hash) ? Hashie::Mash.new(x) : x }
|
28
|
+
else
|
29
|
+
result = Hashie::Mash.new(result)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/beamly/epg.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Beamly
|
2
|
+
class Epg
|
3
|
+
|
4
|
+
def prefix_url
|
5
|
+
"/epg/1/"
|
6
|
+
end
|
7
|
+
|
8
|
+
include Beamly::Client
|
9
|
+
|
10
|
+
def regions
|
11
|
+
get( Beamly.configuration.region.downcase + '/regions')
|
12
|
+
end
|
13
|
+
|
14
|
+
def providers
|
15
|
+
get(Beamly.configuration.region.downcase + '/providers')
|
16
|
+
end
|
17
|
+
|
18
|
+
def catalogues(region, provider)
|
19
|
+
url = Curl::urlalize("which-catalogue?", {:country => Beamly.configuration.region.downcase, :region => region, :provider => provider})
|
20
|
+
get("#{url}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def epg(id)
|
24
|
+
get("epg/#{id}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def schedule(id,date=Date.today.strftime("%Y/%m/%d"))
|
28
|
+
get("service/#{id}/#{date}")
|
29
|
+
end
|
30
|
+
|
31
|
+
def broadcast_event(id)
|
32
|
+
get("broadcastevent/#{id}")
|
33
|
+
end
|
34
|
+
|
35
|
+
def episode(id)
|
36
|
+
get("episode/#{id}")
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/beamly/error.rb
ADDED
data/lib/beamly.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'beamly/client'
|
2
|
+
require 'beamly/epg'
|
3
|
+
require 'beamly/buzz'
|
4
|
+
require 'beamly/configuration'
|
5
|
+
require 'beamly/error'
|
6
|
+
require 'curb'
|
7
|
+
require 'hashie'
|
8
|
+
require 'json'
|
9
|
+
|
10
|
+
# Ruby toolkit for the Beamly API
|
11
|
+
module Beamly
|
12
|
+
|
13
|
+
US = 'api'
|
14
|
+
UK = 'api-uk'
|
15
|
+
AU = 'api-au'
|
16
|
+
|
17
|
+
class << self
|
18
|
+
|
19
|
+
attr_writer :configuration
|
20
|
+
|
21
|
+
def configuration
|
22
|
+
@configuration ||= Configuration.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def configure
|
26
|
+
yield configuration
|
27
|
+
end
|
28
|
+
alias_method :config, :configuration
|
29
|
+
|
30
|
+
def base_uri
|
31
|
+
region = AU
|
32
|
+
if ['US','UK','AU'].include? @configuration.region
|
33
|
+
region = self.const_get(@configuration.region)
|
34
|
+
end
|
35
|
+
"https://#{region}.zeebox.com"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: beamly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2.beta
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kieran Anddrews
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-09 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.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: curb
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hashie
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: rake
|
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
|
+
description: Simple wrapper for the Beamly API
|
70
|
+
email:
|
71
|
+
- hiddentiger@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- Readme.md
|
77
|
+
- beamly.gemspec
|
78
|
+
- lib/beamly.rb
|
79
|
+
- lib/beamly/buzz.rb
|
80
|
+
- lib/beamly/client.rb
|
81
|
+
- lib/beamly/configuration.rb
|
82
|
+
- lib/beamly/epg.rb
|
83
|
+
- lib/beamly/error.rb
|
84
|
+
- lib/beamly/version.rb
|
85
|
+
homepage: https://github.com/TigerWolf/beamly
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.9.2
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>'
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.3.1
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.2.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Ruby toolkit for working with the Beamly API
|
109
|
+
test_files: []
|
110
|
+
has_rdoc:
|