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 beacon
.append('tivoconnect=1')
21 beacon
.append('swversion=1')
22 beacon
.append('method=broadcast')
23 beacon
.append('identity={AD78BB50-6E59-45E3-B955-1CA740E434C9}')
24 beacon
.append('machine=Armooo-Py')
25 beacon
.append('platform=pc')
26 beacon
.append('services=' + self
.format_services())
28 return '\n'.join(beacon
)
30 def send_beacon(self
):
31 self
.UDPSock
.sendto(self
.format_beacon(), ('255.255.255.255', 2190))
33 def send_beacon_timer(self
):
35 t
= Timer(60, self
.send_beacon_timer
)
38 if __name__
== '__main__':
42 b
.add_service('TiVoMediaServer:9032/http')