Permalink
Browse files

Fixed xbmc api wrapper so that params can either be array or single v…

…ariable
  • Loading branch information...
1 parent 1049233 commit 19ca1258f7ef9b51b131d2f6c09f7dc6ca038b4a @ndbroadbent committed Mar 18, 2011
Showing with 3 additions and 3 deletions.
  1. +2 −2 octopus_sinatra.rb
  2. +1 −1 xbmc.rb
View
@@ -108,9 +108,9 @@ def xbmc_trigger(name)
# Pick a random station, and play it.
station = stations[rand(stations.size)]
# Set volume to 45
- xbmc_api("XBMC.SetVolume", %Q{"40"})
+ xbmc_api("XBMC.SetVolume", %Q["40"])
# Play the station.
- xbmc_api("XBMC.Play", %Q{"file":"#{station.gsub(" ", "%20")}"}, :ignore)
+ xbmc_api("XBMC.Play", %Q[{"file":"#{station.gsub(" ", "%20")}"}], :ignore)
end
end
end
View
@@ -4,7 +4,7 @@ def xbmc_api(method, params, ignore_response=false)
req = Net::HTTP::Post.new(url.path)
req.basic_auth $config["xbmc_username"], $config["xbmc_password"]
req.add_field 'Content-Type', 'application/json'
- req.body = %Q[{"method":"#{method}","params":{#{params}},"id":1,"jsonrpc":"2.0"}]
+ req.body = %Q[{"method":"#{method}","params":#{params},"id":1,"jsonrpc":"2.0"}]
begin
# fetch ip from system nslookup. ruby seems to hang a lot on DNS lookups.
if ip_addr = `nslookup #{url.host}`[Regexp.new('Address 1: (\d+\.\d+\.\d+\.\d+) ' << url.host), 1]

0 comments on commit 19ca125

Please sign in to comment.