Skip to content

Commit

Permalink
Simple initial implementation for TiVo (issue #41) - just play/pause.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesremuscat committed May 9, 2014
1 parent 5a2e5df commit 1e9981b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/org/muscat/avx/devices/Tivo.py
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")

0 comments on commit 1e9981b

Please sign in to comment.