Skip to content

Instantly share code, notes, and snippets.

@tedb
Created May 8, 2012 03:22
Show Gist options
  • Save tedb/2632292 to your computer and use it in GitHub Desktop.
Save tedb/2632292 to your computer and use it in GitHub Desktop.
This is a tiny Roku client that controls Roku over the network (similar to the Android app "Romote"), as documented at http://forums.roku.com/viewtopic.php?t=20106
#!/usr/bin/ruby
require 'net/telnet'
class RokuClient
attr_accessor :connection
def initialize(ip, port = 8080)
@connection = Net::Telnet::new(
"Host" => ip,
"Port" => port,
"Timeout" => 5,
"Telnetmode" => false,
"Prompt" => ">"
)
yield(self) if block_given?
end
def method_missing(method)
raise ArgumentError "method invalid" unless [:up, :down, :left, :right, :select, :home, :fwd, :back, :pause].include?(method)
STDERR.puts "press " + method.to_s
@connection.cmd "press " + method.to_s
end
end
# this script can be invoked on the command line:
# $ ruby roku.rb 192.168.1.2 pause
if __FILE__ == $0
RokuClient.new(ARGV[0]) do |r|
r.send ARGV[1].to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment