2 from threading
import Timer
6 UDPSock
= socket(AF_INET
, SOCK_DGRAM
)
7 UDPSock
.setsockopt(SOL_SOCKET
, SO_BROADCAST
, 1)
10 def add_service(self
, service
):
11 self
.services
.append(service
)
14 def format_services(self
):
15 return ';'.join(self
.services
)
17 def format_beacon(self
):
20 from Config
import config
22 if config
.has_option('Server', 'GUID'):
23 guid
= config
.get('Server', 'GUID')
27 beacon
.append('tivoconnect=1')
28 beacon
.append('swversion=1')
29 beacon
.append('method=broadcast')
30 beacon
.append('identity=%s' % guid
)
33 beacon
.append('machine=%s' % socket
.gethostname())
34 beacon
.append('platform=pc')
35 beacon
.append('services=' + self
.format_services())
37 return '\n'.join(beacon
)
39 def send_beacon(self
):
40 self
.UDPSock
.sendto(self
.format_beacon(), ('255.255.255.255', 2190))
44 self
.timer
= Timer(60, self
.start
)
50 if __name__
== '__main__':
54 b
.add_service('TiVoMediaServer:9032/http')