bravtroller 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/bin/bravtroller +108 -0
- data/bravtroller.gemspec +2 -0
- data/lib/bravtroller/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1d0184df45752d732afd8c32940b0e7ef4907ef
|
4
|
+
data.tar.gz: d97cfb17fcf06714b9e5ab574f36e048a92a2c76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b251cc11ed1a5ac097b3af5f20dbcd51e429488e678d43feaf14312f25939852e8ee4c6ce0d3346e33ccd113293332e0d6eacb9f324209a51ecc49f1d2f3ce59
|
7
|
+
data.tar.gz: 0c42e01fa3c6bf5da64d5f6e2ccf5e35cc4d7e88c3fd6af23de5e04b5e5010621c51aa1f869fa04e47feac3103ebfaed4b273dfce07fc42200e24640fddfbd06
|
data/bin/bravtroller
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'json'
|
7
|
+
require 'pp'
|
8
|
+
|
9
|
+
require 'bravtroller'
|
10
|
+
|
11
|
+
options = {}
|
12
|
+
|
13
|
+
banner = <<-BANNER
|
14
|
+
By default, chooses an arbitrary Bravia device on the network. Use the --host
|
15
|
+
option to specify a host manually.
|
16
|
+
|
17
|
+
Usage: bravtroller [OPTIONS]
|
18
|
+
BANNER
|
19
|
+
|
20
|
+
opts = OptionParser.new do |opts|
|
21
|
+
opts.banner = banner
|
22
|
+
|
23
|
+
opts.on('-h', '--host [HOST]', "Connects to HOST") do |v|
|
24
|
+
options[:host] = v
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on("-a", "--authenticate", "Authenticate with the TV") do
|
28
|
+
options[:authenticate] = true
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("--on", "Turn on the TV") do |v|
|
32
|
+
options[:on] = true
|
33
|
+
end
|
34
|
+
|
35
|
+
opts.on("--off", "Turn off the TV") do
|
36
|
+
options[:off] = false
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-l", "--list", "Prints a list of all button names") do |v|
|
40
|
+
options[:list] = true
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on("-b", "--button [BUTTON]", String, "Send command to press BUTTON") do |b|
|
44
|
+
options[:buttons] ||= []
|
45
|
+
options[:buttons].push(b)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.parse!
|
50
|
+
|
51
|
+
host = nil
|
52
|
+
search_results = nil
|
53
|
+
|
54
|
+
if !options[:host].nil?
|
55
|
+
host = options[:host]
|
56
|
+
end
|
57
|
+
|
58
|
+
def ssdp_search
|
59
|
+
EasyUpnp::SsdpSearcher.new.search(Bravtroller::Remote::IRCC_URN)
|
60
|
+
end
|
61
|
+
|
62
|
+
if host.nil?
|
63
|
+
puts "Searching for a TV..."
|
64
|
+
|
65
|
+
search_results = ssdp_search
|
66
|
+
|
67
|
+
if !search_results.any?
|
68
|
+
warn "Couldn't find a device that looked like a Bravia TV on the network."
|
69
|
+
exit 1
|
70
|
+
end
|
71
|
+
|
72
|
+
host = search_results.first.host
|
73
|
+
|
74
|
+
puts "TV found: #{host}"
|
75
|
+
end
|
76
|
+
|
77
|
+
if options[:authenticate]
|
78
|
+
authenticator = Bravtroller::Authenticator.new(host)
|
79
|
+
|
80
|
+
begin
|
81
|
+
authenticator.authorize do
|
82
|
+
puts "You should see a four digit code displayed on the TV. Enter it here: "
|
83
|
+
print "> "
|
84
|
+
gets.chop
|
85
|
+
end
|
86
|
+
rescue Bravtroller::AuthorizationError => e
|
87
|
+
warn "Authorization failed! Make sure you entered the code correctly."
|
88
|
+
exit 1
|
89
|
+
end
|
90
|
+
|
91
|
+
puts "Authentication successful!"
|
92
|
+
end
|
93
|
+
|
94
|
+
remote = Bravtroller::Remote.new(host)
|
95
|
+
buttons = nil
|
96
|
+
|
97
|
+
if options[:list]
|
98
|
+
buttons = remote.buttons
|
99
|
+
puts buttons.sort.join(' ')
|
100
|
+
end
|
101
|
+
|
102
|
+
if options[:buttons]
|
103
|
+
buttons ||= remote.buttons
|
104
|
+
|
105
|
+
options[:buttons].each do |btn|
|
106
|
+
remote.press_button(btn)
|
107
|
+
end
|
108
|
+
end
|
data/bravtroller.gemspec
CHANGED
data/lib/bravtroller/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bravtroller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Mullins
|
@@ -41,7 +41,8 @@ dependencies:
|
|
41
41
|
description: Controller for the Bravia KDL-50W700B supporting WOL and IRCC (Remote
|
42
42
|
Control emulation). Likely supports other Sony devivces that expose the same services
|
43
43
|
email: chris@sidoh.org
|
44
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- bravtroller
|
45
46
|
extensions: []
|
46
47
|
extra_rdoc_files: []
|
47
48
|
files:
|
@@ -51,6 +52,7 @@ files:
|
|
51
52
|
- LICENSE
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
55
|
+
- bin/bravtroller
|
54
56
|
- bravtroller.gemspec
|
55
57
|
- lib/bravtroller.rb
|
56
58
|
- lib/bravtroller/authenticator.rb
|