Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Got tivo command line app working for a few commands
- Loading branch information
Showing
6 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
coverage | ||
rdoc | ||
pkg | ||
.rake_tasks |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
#! ruby | ||
require File.dirname(__FILE__) + '/../lib/dvrb' | ||
|
||
require 'net/telnet' | ||
|
||
tivo = Net::Telnet.new("Host" => '192.168.1.111', 'Port' => '31339', "Timeout" => 5, "Prompt" => /LOCAL/) { |str| print str } | ||
puts "Channel Up" | ||
tivo.cmd "IRCODE CHANNELUP" | ||
tivo.close | ||
|
||
if ARGV.size != 2 | ||
puts <<-EOS | ||
Control you TiVo from the command line. | ||
Usage: | ||
tivo <host> <command> | ||
where available commands are: | ||
play | ||
pause | ||
EOS | ||
else | ||
|
||
tivo = DVRB::Tivo.new(ARGV[0]) | ||
|
||
case ARGV[1] | ||
when "pause" | ||
tivo.pause | ||
when "play" | ||
tivo.play | ||
when "channelup" | ||
tivo.channel_up | ||
when "channeldown" | ||
tivo.channel_down | ||
end | ||
|
||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module DVRB | ||
end | ||
module DVRB; end | ||
|
||
require File.dirname(__FILE__) + '/dvrb/base.rb' | ||
require 'net/telnet' | ||
require 'dvrb/base' | ||
require 'dvrb/tivo' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
class DVRB::Base | ||
attr_accessor :host, :port | ||
|
||
def initialize(host, port) | ||
@host = host | ||
@port = port | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
class DVRB::Tivo < DVRB::Base | ||
|
||
PORT = 31339 | ||
|
||
def initialize(host) | ||
@host = host | ||
end | ||
|
||
def channel_up | ||
send_to_tivo "CHANNELUP" | ||
end | ||
|
||
def channel_down | ||
send_to_tivo "CHANNELDOWN" | ||
end | ||
|
||
def pause | ||
send_to_tivo "PAUSE" | ||
end | ||
|
||
def play | ||
send_to_tivo "PLAY" | ||
end | ||
|
||
private | ||
|
||
def send_to_tivo(command) | ||
tivo = Net::Telnet.new("Host" => @host, 'Port' => PORT, "Timeout" => 5, "Prompt" => /LOCAL/) | ||
tivo.cmd "IRCODE #{command}" | ||
tivo.close | ||
end | ||
|
||
end |