Skip to content
Snippets Groups Projects
Commit 1b4c67c7 authored by Jess Ward's avatar Jess Ward
Browse files

put zeroconf into function, added get_client logic

parent e0d0ab6f
No related branches found
No related tags found
No related merge requests found
from zeroconf import ServiceBrowser, Zeroconf from zeroconf import ServiceBrowser, Zeroconf
import snapcast.control
class Scanner: class Scanner:
services = []
def remove_service(self, zeroconf, type, name): def remove_service(self, zeroconf, type, name):
print("Service %s removed" % (name,)) print("Service %s removed" % (name,))
def add_service(self, zeroconf, type, name): def add_service(self, zeroconf, type, name):
snapcast_server = []
info = zeroconf.get_service_info(type, name) info = zeroconf.get_service_info(type, name)
snapcast_server.append(name, info) self.services.append(info)
zeroconf = Zeroconf() def get_snapcast_server(services):
listener = Scanner() '''scan for services then find snapcast server'''
browser = ServiceBrowser(zeroconf, "_snapcast._tcp.local.", listener) zeroconf = Zeroconf()
listener = Scanner()
ServiceBrowser(zeroconf, "_snapcast._tcp.local.", listener)
server = snapcast.control.Snapserver(services, snapcast.control.
CONTROL.PORT)
try: while services == []:
input("Press enter to exit...\n\n") pass
finally: return server
zeroconf.close()
def get_snapcast_client(): def get_snapcast_client(server):
pass '''scan through list of clients to find correct one'''
for client in server.clients:
print(client.name)
print(client.identifier)
# TODO Scroll through list of clients and find right one # TODO Scroll through list of clients and find right one
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment