Created
May 8, 2012 03:22
-
-
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
This file contains hidden or 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
#!/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