-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscovery.py
47 lines (36 loc) · 1.04 KB
/
discovery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import time
from roonapi import RoonApi, RoonDiscovery
appinfo = {
"extension_id": "roon_cad",
"display_name": "Python program to display cover art on display",
"display_version": "1.0.0",
"publisher": "jason-a69",
"email": "[email protected]",
}
discover = RoonDiscovery(None)
servers = discover.all()
print("Shutdown discovery")
discover.stop()
print("Found the following servers")
print(servers)
apis = [RoonApi(appinfo, None, server[0], server[1], False) for server in servers]
auth_api = []
while len(auth_api) == 0:
print("Waiting for authorisation")
time.sleep(1)
auth_api = [api for api in apis if api.token is not None]
api = auth_api[0]
print("Received authorisation")
print(api.host)
print(api.core_name)
print(api.core_id)
print("Shutdown apis")
for api in apis:
api.stop()
# This is what we need to reconnect
core_id = api.core_id
token = api.token
with open("/etc/roon_cad/my_core_id_file", "w") as f:
f.write(api.core_id)
with open("/etc/roon_cad/my_token_file", "w") as f:
f.write(api.token)