2009-05-11, 15:15
I'm trying to write a script to display popups on XBMC from another computer.
1. Is there some way to bust the 32-character limit?
2. How do I escape a comma? Even if I URL encode it, XBMC still interprets it as if it were a comma.
Here's a sample. This will display "eat cake" only.
1. Is there some way to bust the 32-character limit?
2. How do I escape a comma? Even if I URL encode it, XBMC still interprets it as if it were a comma.
Here's a sample. This will display "eat cake" only.
Code:
#!/usr/bin/ruby
require 'cgi'
require 'net/http'
require 'uri'
XBMC_HOST = 'yuki'
XBMC_USER = ''
XBMC_PASS = ''
# 32 character max
MESSAGE = "eat cake, live longer"
escaped_message = CGI.escape(MESSAGE)
req = Net::HTTP::Get.new("/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(Informational,#{escaped_message}))")
req.basic_auth(XBMC_USER, XBMC_PASS)
res = Net::HTTP.new(XBMC_HOST, 8080).start { |http| http.request(req) }
case res
when Net::HTTPSuccess
# OK
else
res.error!
end