Created
December 9, 2012 13:36
-
-
Save mvilrokx/4244910 to your computer and use it in GitHub Desktop.
Siri Proxy Squeezebox plugin: the squeezebox class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Squeezebox | |
def initialize(config = {}) | |
puts 'enter initialize in Squeezebox' | |
@t = Net::Telnet::new( | |
'Host' => config['host']||'localhost', | |
'Port' => config['port']||9090, | |
'Prompt' => /./ # needed to work | |
) | |
@id_set = false | |
@id = self.player('id ?') | |
@id_set = true | |
puts 'leave initialize in Squeezebox' | |
end | |
def method_missing(method,*args) | |
args = args * ' ' | |
regex = [method.to_s,args.to_s].join(' ').sub(/\s\?/,'') + '\s\??\s?' | |
regex = @id_set ? ['(' + @id + ' )?',regex].join(): regex | |
regex = Regexp.new(regex) | |
rs = URI.decode(@t.cmd("#{method} #{args}").strip!) | |
rs.sub!(regex,'') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment