Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dark-Mute
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jess Ward
Dark-Mute
Commits
e0c73a61
Commit
e0c73a61
authored
6 years ago
by
Jess Ward
Browse files
Options
Downloads
Patches
Plain Diff
async loop moved to darkmute file.
Minor comment changes:
parent
a61eadd7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
snap.py
+7
-9
7 additions, 9 deletions
snap.py
with
7 additions
and
9 deletions
snap.py
+
7
−
9
View file @
e0c73a61
from
zeroconf
import
ServiceBrowser
,
Zeroconf
import
snapcast.control
import
asyncio
import
ipaddress
import
netifaces
...
...
@@ -17,7 +16,7 @@ class Scanner:
self
.
services
.
append
(
info
)
def
get_snapcast_server
():
def
get_snapcast_server
(
loop
):
'''
Scan for services then find snapcast server.
'''
zeroconf
=
Zeroconf
()
listener
=
Scanner
()
...
...
@@ -26,8 +25,6 @@ def get_snapcast_server():
while
listener
.
services
==
[]:
pass
# Snapcast library only supports asynchronous so need to wrap in async loop
loop
=
asyncio
.
get_event_loop
()
server_ip_bytes
=
listener
.
services
[
0
].
address
server_ip
=
str
(
ipaddress
.
ip_address
(
server_ip_bytes
))
# Snapserver.__init__ does not work in snapcast==2.0.8
...
...
@@ -37,7 +34,6 @@ def get_snapcast_server():
create_server_coroutine
=
snapcast
.
control
.
create_server
(
loop
,
server_ip
,
reconnect
=
True
)
server
=
loop
.
run_until_complete
(
create_server_coroutine
)
loop
.
close
()
return
server
...
...
@@ -66,9 +62,11 @@ def get_mac_addresses():
return
mac_addresses
def
get_snapcast_client
(
server
):
def
get_snapcast_client
(
loop
):
'''
Scan through list of clients to find correct one.
'''
server
=
get_snapcast_server
(
loop
)
mac_addresses
=
get_mac_addresses
()
for
client
in
server
.
clients
:
print
(
client
.
name
)
print
(
client
.
identifier
)
# TODO Scroll through list of clients and find right one
#
print(client.
identifier
)
if
client
.
identifier
in
mac_addresses
:
return
client
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment