dtvcontroller 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/dtvcontroller.rb +96 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bddbb04ba73cbdb19fb21f2e8d15f103568f4701
|
4
|
+
data.tar.gz: fe230bcb719097205519a4f29fd0d2e9d542de39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0404c2267e2d16a5c6dec837b693b90559855a08925260fca93db9b438e3be55da21524874c345a9f7f9c924847a8803c42bd452b683934ccf21e4e9e42044df
|
7
|
+
data.tar.gz: 1cbfd9837855a7ee3d7afe7b7479798160edafd22bc4aa3b3e0d41bec74f4042ce4905fe4e391d7cd57199847643572347c5fd3ff3b9cc548d6b75d119badf03
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#####################################
|
2
|
+
# Example Usage:
|
3
|
+
# control = Dtvcontroller.new("192.168.1.100")
|
4
|
+
#
|
5
|
+
# Getting current channel:
|
6
|
+
# puts control.get_channel => "529: SEDGHD - The Lost World: Jurassic Park"
|
7
|
+
#
|
8
|
+
# Tuning to a certain channel:
|
9
|
+
# a = "206"
|
10
|
+
# control.tune(a) => "" *if 'msg' is not 'OK.' 'msg' will be RETURNED
|
11
|
+
#
|
12
|
+
# Sending a remote key:
|
13
|
+
# a = "ch_up"
|
14
|
+
# control.send_key(a) => ""
|
15
|
+
#
|
16
|
+
# Getting information from systeminfo
|
17
|
+
# a = "accessCardId"
|
18
|
+
# b = control.get_sysinfo(a)
|
19
|
+
# puts b => "0918 9292 1846"
|
20
|
+
#
|
21
|
+
# If connection fails because of timeout
|
22
|
+
# for any method, "Can't Connect." will be RETURNED.
|
23
|
+
#######################################
|
24
|
+
|
25
|
+
require 'net/http'
|
26
|
+
require 'json'
|
27
|
+
|
28
|
+
class Dtvcontroller
|
29
|
+
|
30
|
+
def initialize(n)
|
31
|
+
@ip = n
|
32
|
+
end
|
33
|
+
|
34
|
+
def ver
|
35
|
+
puts "1"
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_channel
|
39
|
+
uri = URI('http://' + @ip + ':8080/tv/getTuned')
|
40
|
+
|
41
|
+
begin
|
42
|
+
result = Net::HTTP.get(uri)
|
43
|
+
response = JSON.parse(result)
|
44
|
+
|
45
|
+
if response["episodeTitle"] == nil # Not allow programs have an 'episodetitle'. However, from my experience, all have a 'title' at the least.
|
46
|
+
return response["major"].to_s + ': ' + response["callsign"] + ' - ' + response["title"] # Callsign is the channel 'name'
|
47
|
+
else
|
48
|
+
return response["major"].to_s + ': ' + response["callsign"] + ' - ' + response["title"] + ': ' + response["episodeTitle"]
|
49
|
+
end
|
50
|
+
|
51
|
+
rescue Errno::ETIMEDOUT => e
|
52
|
+
return "Can't Connect"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def tune(chan)
|
57
|
+
if chan == ''
|
58
|
+
return 'no input'
|
59
|
+
else
|
60
|
+
uri = URI('http://' + @ip + ':8080/tv/tune?major=' + chan)
|
61
|
+
|
62
|
+
begin
|
63
|
+
result = Net::HTTP.get(uri)
|
64
|
+
response = JSON.parse(result)
|
65
|
+
parse = response["status"]
|
66
|
+
message = parse["msg"]
|
67
|
+
if message != "OK."
|
68
|
+
return message
|
69
|
+
end
|
70
|
+
|
71
|
+
rescue Errno::ETIMEDOUT => e
|
72
|
+
return "Can't Connect"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
#key-list: power, poweron, poweroff, format, pause, rew, replay, stop, advance, ffwd, record, play, guide, active, list, exit, back, menu, info, up, down, left, right, select, red, green, yellow, blue, ch_up, ch_dn, prev, 0-9, dash(or '-'), enter
|
78
|
+
def send_key(key)
|
79
|
+
uri = URI("http://" + @ip + ":8080/remote/processKey?key=" + key)
|
80
|
+
begin
|
81
|
+
Net::HTTP.get(uri)
|
82
|
+
rescue Errno::ETIMEDOUT => e
|
83
|
+
return "Can't Connect"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
#possible requests: accessCardId, receiverId, stbSoftwareVersion, version
|
88
|
+
def get_sysinfo(request)
|
89
|
+
uri = URI("http://" + @ip + ":8080/info/getVersion")
|
90
|
+
a = Net::HTTP.get(uri)
|
91
|
+
result = JSON.parse(a)
|
92
|
+
parse = result[request]
|
93
|
+
return parse
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dtvcontroller
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nicholas M. Petty
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Allows control of DirecTV Set Top Boxes whoms Whole-Home -> External
|
14
|
+
Device settings are set to Allow
|
15
|
+
email:
|
16
|
+
- nick@ihackeverything.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/dtvcontroller.rb
|
22
|
+
homepage: http://github.com/nickpetty/dtvcontroller-gem
|
23
|
+
licenses: []
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.0.0
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: DirecTV STB Controller
|
45
|
+
test_files: []
|