Skip to content

Commit

Permalink
Merge pull request #2 from SantiagoSotoC/add-path-property-to-stream
Browse files Browse the repository at this point in the history
Add path property to stream
  • Loading branch information
SantiagoSotoC authored Oct 28, 2023
2 parents 34533df + d1cdf37 commit c724ca6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ snapcast.egg-info*
.cache
.coverage
.tox
.venv
dist
MANIFEST
.venv
dist
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

0 comments on commit c724ca6

Please sign in to comment.