Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path property to stream #2

Merged
merged 5 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ snapcast.egg-info*
.cache
.coverage
.tox
.venv
dist
MANIFEST
20 changes: 19 additions & 1 deletion snapcast/control/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
STREAM_SETMETA = 'Stream.SetMeta' # deprecated
STREAM_ONUPDATE = 'Stream.OnUpdate'
STREAM_ONMETA = 'Stream.OnMetadata' # deprecated
STREAM_ADDSTREAM = 'Stream.AddStream'
STREAM_REMOVESTREAM = 'Stream.RemoveStream'

SERVER_RECONNECT_DELAY = 5

Expand All @@ -55,12 +57,15 @@
SERVER_DELETECLIENT, CLIENT_GETSTATUS, CLIENT_SETNAME,
CLIENT_SETLATENCY, CLIENT_SETVOLUME,
GROUP_GETSTATUS, GROUP_SETMUTE, GROUP_SETSTREAM, GROUP_SETCLIENTS,
GROUP_SETNAME, STREAM_SETMETA, STREAM_SETPROPERTY, STREAM_CONTROL]
GROUP_SETNAME, STREAM_SETMETA, STREAM_SETPROPERTY, STREAM_CONTROL,
STREAM_ADDSTREAM, STREAM_REMOVESTREAM ]

# server versions in which new methods were added
_VERSIONS = {
GROUP_SETNAME: '0.16.0',
STREAM_SETPROPERTY: '0.26.0',
STREAM_ADDSTREAM: '0.26.0',
STREAM_REMOVESTREAM: '0.26.0',
}


Expand Down Expand Up @@ -238,6 +243,19 @@ def stream_setproperty(self, identifier, stream_property, value):
'value': value
})

async def stream_add_stream(self, stream_uri):
"""Add a stream."""
params = {"streamUri" : stream_uri}
result = await self._transact(STREAM_ADDSTREAM, params)
status = await self.status()
self._on_server_update(status)
return result

async def stream_remove_stream(self, identifier):
"""Remove a Stream."""
result = await self._request(STREAM_REMOVESTREAM, identifier)
return result

def group(self, group_identifier):
"""Get a group."""
return self._groups[group_identifier]
Expand Down
8 changes: 7 additions & 1 deletion snapcast/control/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ def meta(self):
def properties(self):
"""Get properties."""
return self._stream.get('properties')


@property
def path(self):
"""Get stream path."""
return self._stream.get('uri').get('path')

@property
def update(self, data):
"""Update stream."""
self._stream = data
Expand Down
Loading