-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple initial implementation for TiVo (issue #41) - just play/pause.
- Loading branch information
1 parent
5a2e5df
commit 1e9981b
Showing
1 changed file
with
36 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from org.muscat.avx.devices.Device import Device | ||
from socket import socket | ||
|
||
|
||
class Tivo(Device): | ||
''' | ||
A networked TiVo device. Developed against Virgin Media UK's TiVo boxes. | ||
''' | ||
|
||
socket = None | ||
|
||
def __init__(self, deviceID, ipAddress, port=31339, **kwargs): | ||
super(Tivo, self).__init__(deviceID) | ||
self.ipAddress = ipAddress | ||
self.port = port | ||
|
||
def initialise(self): | ||
self.socket = socket() | ||
self.socket.settimeout(5) | ||
self.socket.connect((self.ipAddress, self.port)) | ||
|
||
def send(self, message): | ||
if not self.socket: | ||
self.initialise() | ||
self.socket.sendall(message) | ||
|
||
def sendIRCode(self, ircode): | ||
self.send('IRCODE %s\r' % ircode) | ||
|
||
# On to the actual functions | ||
|
||
def pause(self): | ||
self.sendIRCode("PAUSE") | ||
|
||
def play(self): | ||
self.sendIRCode("PLAY") |