4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/zeebox/client.rb', line 4
def self.get(url)
response = Curl.get(Zeebox.base_uri + EPG_URI + url) do |http|
http.['zeebox-app-id'] = Zeebox.configuration.id
http.['zeebox-app-key'] = Zeebox.configuration.key
http.["Accept-Encoding"] = "gzip,deflate"
http.follow_location = true
end
return "" if response.body_str.empty?
gz = Zlib::GzipReader.new(StringIO.new(response.body_str))
json = gz.read
result = JSON.parse json
if result.is_a? Array
result.collect! { |x| x.is_a?(Hash) ? Hashie::Mash.new(x) : x }
else
result = Hashie::Mash.new(result)
end
end
|