dvrb 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ .rake_tasks
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Marshall Huss
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ h1. dvrb
2
+
3
+ Ruby interface and command line application to control DVR's like TiVo and MythTV.
4
+
5
+ h2. Currently Supported
6
+ * TiVo Series 3
7
+ * TiVo HD
8
+ * TiVo HD XL
9
+
10
+ h2. On the List
11
+
12
+ * "TivoWebPlus":http://en.wikipedia.org/wiki/Tivoweb
13
+ * "MythTV":http://www.mythtv.org/wiki/Telnet_socket
14
+ * "Boxee":http://developer.boxee.tv/
15
+ * "XBMC":http://xbmc.org/wiki/?title=Web_Server_HTTP_API
16
+
17
+ h2. Usage
18
+
19
+ h3. Network Remote for TiVo
20
+
21
+ For this to work you need to enable Network Remote Control
22
+
23
+ <pre>
24
+ <code>
25
+ Messages & Settings > Settings > Remote, CableCARDS, & Devices > Network Remote Control > Enable
26
+ </pre>
27
+ </code>
28
+
29
+ h3. Command Line
30
+
31
+ <pre>
32
+ <code>
33
+ > tivo
34
+ Control you TiVo from the command line.
35
+
36
+ Usage:
37
+ tivo <host> <command>
38
+
39
+ where available commands are:
40
+ play
41
+ pause
42
+ record
43
+ select
44
+ number #
45
+ channel ###
46
+ channel_up
47
+ channel_down
48
+ up
49
+ down
50
+ left
51
+ right
52
+ tivo
53
+ thumbs_up
54
+ thumbs_down
55
+ live_tv
56
+ now_showing
57
+ </pre>
58
+ </code>
59
+
60
+ h3. API
61
+
62
+ <pre>
63
+ <code>
64
+ tivo = DVRB::Tivo.new(ip_address)
65
+ tivo.pause
66
+ tivo.play
67
+ </pre>
68
+ </code>
69
+
70
+ h2. Copyright
71
+
72
+ Copyright (c) 2009 Marshall Huss. See LICENSE for details.
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "dvrb"
8
+ gem.summary = "Ruby interface and command line application to control DVR's like TiVo and MythTV"
9
+ gem.description = gem.summary
10
+ gem.email = "mwhuss@gmail.com"
11
+ gem.homepage = "http://github.com/mwhuss/dvrb"
12
+ gem.authors = ["Marshall Huss"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+
41
+ task :default => :test
42
+
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ if File.exist?('VERSION.yml')
46
+ config = YAML.load(File.read('VERSION.yml'))
47
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "dvrb #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
57
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,49 @@
1
+ #! ruby
2
+ require File.dirname(__FILE__) + '/../lib/dvrb'
3
+
4
+ banner = <<-EOS
5
+ Control you TiVo from the command line.
6
+
7
+ Usage:
8
+ tivo <host> <command>
9
+
10
+ where available commands are:
11
+ play
12
+ pause
13
+ record
14
+ select
15
+ number #
16
+ channel ###
17
+ channel_up
18
+ channel_down
19
+ up
20
+ down
21
+ left
22
+ right
23
+ tivo
24
+ thumbs_up
25
+ thumbs_down
26
+ live_tv
27
+ now_showing
28
+ EOS
29
+
30
+ if ARGV.size < 2 || ARGV.size > 3
31
+ puts banner
32
+ else
33
+
34
+ tivo = DVRB::Tivo.new(ARGV[0])
35
+
36
+ begin
37
+ ARGV[2].nil? ? tivo.send(ARGV[1]) : tivo.send(ARGV[1], ARGV[2])
38
+
39
+ rescue NoMethodError
40
+ puts "[Error] Invalid Command.\n\n"
41
+ puts banner
42
+ rescue SocketError
43
+ puts "[Error] Issue connecting to the TiVo, check the host name and make sure you have Network Remote enabled on your TiVo."
44
+ rescue Timeout::Error
45
+ puts "[Error] TiVo timed out"
46
+ end
47
+
48
+
49
+ end
@@ -0,0 +1,52 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{dvrb}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Marshall Huss"]
9
+ s.date = %q{2009-06-12}
10
+ s.default_executable = %q{tivo}
11
+ s.description = %q{Ruby interface and command line application to control DVR's like TiVo and MythTV}
12
+ s.email = %q{mwhuss@gmail.com}
13
+ s.executables = ["tivo"]
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.textile"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.textile",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "bin/tivo",
26
+ "dvrb.gemspec",
27
+ "lib/dvrb.rb",
28
+ "lib/dvrb/base.rb",
29
+ "lib/dvrb/tivo.rb",
30
+ "test/dvrb_test.rb",
31
+ "test/test_helper.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/mwhuss/dvrb}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.4}
37
+ s.summary = %q{Ruby interface and command line application to control DVR's like TiVo and MythTV}
38
+ s.test_files = [
39
+ "test/dvrb_test.rb",
40
+ "test/test_helper.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ else
49
+ end
50
+ else
51
+ end
52
+ end
@@ -0,0 +1,5 @@
1
+ module DVRB; end
2
+
3
+ require 'net/telnet'
4
+ require 'dvrb/base'
5
+ require 'dvrb/tivo'
@@ -0,0 +1,8 @@
1
+ class DVRB::Base
2
+ attr_accessor :host, :port
3
+
4
+ def initialize(host, port)
5
+ @host = host
6
+ @port = port
7
+ end
8
+ end
@@ -0,0 +1,147 @@
1
+ class DVRB::Tivo < DVRB::Base
2
+
3
+ PORT = 31339
4
+
5
+ attr_accessor :tivo
6
+
7
+ def initialize(host)
8
+ @host = host
9
+ end
10
+
11
+ # Play
12
+ def play
13
+ remote "PLAY"
14
+ end
15
+
16
+ # Pause
17
+ def pause
18
+ remote "PAUSE"
19
+ end
20
+
21
+ # Starts recording the current channel
22
+ def record
23
+ remote "RECORD", "SELECT"
24
+ end
25
+
26
+ # Channel up
27
+ def channel_up
28
+ remote "CHANNELUP"
29
+ end
30
+
31
+ # Channel down
32
+ def channel_down
33
+ remote "CHANNELDOWN"
34
+ end
35
+
36
+ def select
37
+ remote "SELECT"
38
+ end
39
+
40
+ # Input a number
41
+ def number(num)
42
+ remote "NUM#{num}"
43
+ end
44
+
45
+ # Changes the channel
46
+ def channel(num)
47
+ num.to_s.split("").each { |n| number(n) }
48
+ end
49
+
50
+ def up
51
+ remote "UP"
52
+ end
53
+
54
+ def down
55
+ remote "DOWN"
56
+ end
57
+
58
+ def left
59
+ remote "LEFT"
60
+ end
61
+
62
+ def right
63
+ remote "RIGHT"
64
+ end
65
+
66
+ # TiVo specific functions
67
+ def tivo
68
+ remote "TIVO"
69
+ end
70
+
71
+ def thumbs_up
72
+ remote "THUMBSUP"
73
+ end
74
+
75
+ def thumbs_down
76
+ remote "THUMBSDOWN"
77
+ end
78
+
79
+ def live_tv
80
+ remote "LIVETV"
81
+ end
82
+
83
+ def now_showing
84
+ remote "NOWSHOWING"
85
+ end
86
+
87
+
88
+
89
+ private
90
+
91
+ def remote(*commands)
92
+ commands.each do |c|
93
+ send_to_tivo c
94
+ sleep 1
95
+ end
96
+ end
97
+
98
+ def send_to_tivo(command)
99
+ tivo = Net::Telnet.new("Host" => @host, 'Port' => PORT, "Timeout" => 5, "Prompt" => /LOCAL|COMMAND_TIMEOUT/)
100
+ tivo.cmd "IRCODE #{command}"
101
+ tivo.close
102
+ end
103
+
104
+ end
105
+
106
+
107
+
108
+ # DISPLAY
109
+ # DIRECTV
110
+ # ENTER
111
+ # CLEAR
112
+ # SLOW
113
+ # FORWARD
114
+ # REVERSE
115
+ # STANDBY
116
+ # NOWSHOWING
117
+ # REPLAY
118
+ # ADVANCE
119
+ # DELIMITER
120
+ # GUIDE
121
+
122
+
123
+ # DONE
124
+ # TIVO
125
+ # NUM0
126
+ # NUM1
127
+ # NUM2
128
+ # NUM3
129
+ # NUM4
130
+ # NUM5
131
+ # NUM6
132
+ # NUM7
133
+ # NUM8
134
+ # NUM9
135
+ # LIVETV
136
+ # THUMBSUP
137
+ # THUMBSDOWN
138
+ # CHANNELUP
139
+ # CHANNELDOWN
140
+ # PLAY
141
+ # PAUSE
142
+ # RECORD
143
+ # UP
144
+ # DOWN
145
+ # LEFT
146
+ # RIGHT
147
+ # SELECT
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class DvrbTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'dvrb'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dvrb
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Marshall Huss
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2009-06-12 00:00:00 -04:00
18
+ default_executable: tivo
19
+ dependencies: []
20
+
21
+ description: Ruby interface and command line application to control DVR's like TiVo and MythTV
22
+ email: mwhuss@gmail.com
23
+ executables:
24
+ - tivo
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - LICENSE
29
+ - README.textile
30
+ files:
31
+ - .document
32
+ - .gitignore
33
+ - LICENSE
34
+ - README.textile
35
+ - Rakefile
36
+ - VERSION
37
+ - bin/tivo
38
+ - dvrb.gemspec
39
+ - lib/dvrb.rb
40
+ - lib/dvrb/base.rb
41
+ - lib/dvrb/tivo.rb
42
+ - test/dvrb_test.rb
43
+ - test/test_helper.rb
44
+ has_rdoc: true
45
+ homepage: http://github.com/mwhuss/dvrb
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --charset=UTF-8
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.3.6
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Ruby interface and command line application to control DVR's like TiVo and MythTV
74
+ test_files:
75
+ - test/dvrb_test.rb
76
+ - test/test_helper.rb