python-linkplay 0.0.10__py3-none-any.whl → 0.0.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- linkplay/__version__.py +1 -1
- linkplay/bridge.py +31 -9
- linkplay/consts.py +19 -0
- linkplay/endpoint.py +12 -1
- {python_linkplay-0.0.10.dist-info → python_linkplay-0.0.12.dist-info}/METADATA +1 -1
- python_linkplay-0.0.12.dist-info/RECORD +15 -0
- {python_linkplay-0.0.10.dist-info → python_linkplay-0.0.12.dist-info}/WHEEL +1 -1
- python_linkplay-0.0.10.dist-info/RECORD +0 -15
- {python_linkplay-0.0.10.dist-info → python_linkplay-0.0.12.dist-info}/LICENSE +0 -0
- {python_linkplay-0.0.10.dist-info → python_linkplay-0.0.12.dist-info}/top_level.txt +0 -0
linkplay/__version__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.0.
|
1
|
+
__version__ = '0.0.12'
|
linkplay/bridge.py
CHANGED
@@ -26,12 +26,15 @@ class LinkPlayDevice:
|
|
26
26
|
"""Represents a LinkPlay device."""
|
27
27
|
|
28
28
|
bridge: LinkPlayBridge
|
29
|
-
properties: dict[DeviceAttribute, str]
|
30
|
-
DeviceAttribute.__members__.values(), ""
|
31
|
-
)
|
29
|
+
properties: dict[DeviceAttribute, str]
|
32
30
|
|
33
31
|
def __init__(self, bridge: LinkPlayBridge):
|
34
32
|
self.bridge = bridge
|
33
|
+
self.properties = dict.fromkeys(DeviceAttribute.__members__.values(), "")
|
34
|
+
|
35
|
+
def to_dict(self):
|
36
|
+
"""Return the state of the LinkPlayDevice."""
|
37
|
+
return {"properties": self.properties}
|
35
38
|
|
36
39
|
async def update_status(self) -> None:
|
37
40
|
"""Update the device status."""
|
@@ -74,12 +77,15 @@ class LinkPlayPlayer:
|
|
74
77
|
"""Represents a LinkPlay player."""
|
75
78
|
|
76
79
|
bridge: LinkPlayBridge
|
77
|
-
properties: dict[PlayerAttribute, str]
|
78
|
-
PlayerAttribute.__members__.values(), ""
|
79
|
-
)
|
80
|
+
properties: dict[PlayerAttribute, str]
|
80
81
|
|
81
82
|
def __init__(self, bridge: LinkPlayBridge):
|
82
83
|
self.bridge = bridge
|
84
|
+
self.properties = dict.fromkeys(PlayerAttribute.__members__.values(), "")
|
85
|
+
|
86
|
+
def to_dict(self):
|
87
|
+
"""Return the state of the LinkPlayPlayer."""
|
88
|
+
return {"properties": self.properties}
|
83
89
|
|
84
90
|
async def update_status(self) -> None:
|
85
91
|
"""Update the player status."""
|
@@ -124,6 +130,11 @@ class LinkPlayPlayer:
|
|
124
130
|
await self.bridge.request(LinkPlayCommand.PAUSE)
|
125
131
|
self.properties[PlayerAttribute.PLAYING_STATUS] = PlayingStatus.PAUSED
|
126
132
|
|
133
|
+
async def stop(self) -> None:
|
134
|
+
"""Stop the current playing track and remove the selected source."""
|
135
|
+
await self.bridge.request(LinkPlayCommand.STOP)
|
136
|
+
self.properties[PlayerAttribute.PLAYING_STATUS] = PlayingStatus.STOPPED
|
137
|
+
|
127
138
|
async def toggle(self) -> None:
|
128
139
|
"""Start playing if the player is currently not playing. Stops playing if it is."""
|
129
140
|
await self.bridge.request(LinkPlayCommand.TOGGLE)
|
@@ -224,9 +235,12 @@ class LinkPlayPlayer:
|
|
224
235
|
@property
|
225
236
|
def play_mode(self) -> PlayingMode:
|
226
237
|
"""Returns the current playing mode of the player."""
|
227
|
-
|
228
|
-
|
229
|
-
|
238
|
+
try:
|
239
|
+
return PlayingMode(
|
240
|
+
self.properties.get(PlayerAttribute.PLAYBACK_MODE, PlayingMode.IDLE)
|
241
|
+
)
|
242
|
+
except ValueError:
|
243
|
+
return PlayingMode(PlayingMode.IDLE)
|
230
244
|
|
231
245
|
@property
|
232
246
|
def loop_mode(self) -> LoopMode:
|
@@ -256,6 +270,14 @@ class LinkPlayBridge:
|
|
256
270
|
|
257
271
|
return self.device.name
|
258
272
|
|
273
|
+
def to_dict(self):
|
274
|
+
"""Return the state of the LinkPlayBridge."""
|
275
|
+
return {
|
276
|
+
"endpoint": self.endpoint.to_dict(),
|
277
|
+
"device": self.device.to_dict(),
|
278
|
+
"player": self.player.to_dict(),
|
279
|
+
}
|
280
|
+
|
259
281
|
async def json_request(self, command: str) -> dict[str, str]:
|
260
282
|
"""Performs a GET request on the given command and returns the result as a JSON object."""
|
261
283
|
return await self.endpoint.json_request(command)
|
linkplay/consts.py
CHANGED
@@ -79,6 +79,7 @@ class LinkPlayCommand(StrEnum):
|
|
79
79
|
VOLUME = "setPlayerCmd:vol:{}"
|
80
80
|
PLAYLIST = "setPlayerCmd:playlist:uri:{}"
|
81
81
|
PAUSE = "setPlayerCmd:pause"
|
82
|
+
STOP = "setPlayerCmd:stop"
|
82
83
|
TOGGLE = "setPlayerCmd:onepause"
|
83
84
|
EQUALIZER_MODE = "setPlayerCmd:equalizer:{}"
|
84
85
|
LOOP_MODE = "setPlayerCmd:loopmode:{}"
|
@@ -304,6 +305,12 @@ class PlayerAttribute(StrEnum):
|
|
304
305
|
VOLUME = "vol"
|
305
306
|
MUTED = "mute"
|
306
307
|
|
308
|
+
def __str__(self):
|
309
|
+
return self.value
|
310
|
+
|
311
|
+
def __repr__(self):
|
312
|
+
return self.value
|
313
|
+
|
307
314
|
|
308
315
|
class DeviceAttribute(StrEnum):
|
309
316
|
"""Defines the device attributes."""
|
@@ -412,6 +419,12 @@ class DeviceAttribute(StrEnum):
|
|
412
419
|
POWER_MODE = "power_mode"
|
413
420
|
SECURITY_CAPABILITIES = "security_capabilities"
|
414
421
|
|
422
|
+
def __str__(self):
|
423
|
+
return self.value
|
424
|
+
|
425
|
+
def __repr__(self):
|
426
|
+
return self.value
|
427
|
+
|
415
428
|
|
416
429
|
class MultiroomAttribute(StrEnum):
|
417
430
|
"""Defines the player attributes."""
|
@@ -420,3 +433,9 @@ class MultiroomAttribute(StrEnum):
|
|
420
433
|
FOLLOWER_LIST = "slave_list"
|
421
434
|
UUID = "uuid"
|
422
435
|
IP = "ip"
|
436
|
+
|
437
|
+
def __str__(self):
|
438
|
+
return self.value
|
439
|
+
|
440
|
+
def __repr__(self):
|
441
|
+
return self.value
|
linkplay/endpoint.py
CHANGED
@@ -3,7 +3,6 @@ from abc import ABC, abstractmethod
|
|
3
3
|
|
4
4
|
from aiohttp import ClientSession
|
5
5
|
|
6
|
-
from linkplay.consts import TCPPORT
|
7
6
|
from linkplay.utils import (
|
8
7
|
call_tcpuart,
|
9
8
|
call_tcpuart_json,
|
@@ -23,6 +22,10 @@ class LinkPlayEndpoint(ABC):
|
|
23
22
|
async def json_request(self, command: str) -> dict[str, str]:
|
24
23
|
"""Performs a request on the given command and returns the result as a JSON object."""
|
25
24
|
|
25
|
+
@abstractmethod
|
26
|
+
def to_dict(self) -> dict[str, str]:
|
27
|
+
"""Return the state of the LinkPlayEndpoint"""
|
28
|
+
|
26
29
|
|
27
30
|
class LinkPlayApiEndpoint(LinkPlayEndpoint):
|
28
31
|
"""Represents a LinkPlay HTTP API endpoint."""
|
@@ -35,6 +38,10 @@ class LinkPlayApiEndpoint(LinkPlayEndpoint):
|
|
35
38
|
self._endpoint: str = f"{protocol}://{endpoint}"
|
36
39
|
self._session: ClientSession = session
|
37
40
|
|
41
|
+
def to_dict(self):
|
42
|
+
"""Return the state of the LinkPlayEndpoint"""
|
43
|
+
return {"endpoint": self._endpoint}
|
44
|
+
|
38
45
|
async def request(self, command: str) -> None:
|
39
46
|
"""Performs a GET request on the given command and verifies the result."""
|
40
47
|
await session_call_api_ok(self._endpoint, self._session, command)
|
@@ -55,6 +62,10 @@ class LinkPlayTcpUartEndpoint(LinkPlayEndpoint):
|
|
55
62
|
):
|
56
63
|
self._connection = connection
|
57
64
|
|
65
|
+
def to_dict(self):
|
66
|
+
"""Return the state of the LinkPlayEndpoint"""
|
67
|
+
return {}
|
68
|
+
|
58
69
|
async def request(self, command: str) -> None:
|
59
70
|
reader, writer = self._connection
|
60
71
|
await call_tcpuart(reader, writer, command)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
linkplay/__init__.py,sha256=y9ZehEq-KhS3cwn-PUpwVSJGfDUx7e5wf_G6guODcTk,56
|
2
|
+
linkplay/__main__.py,sha256=Wcza80QaWfOaHjyJEfQYhB9kiPLE0NOqIj4zVWv2Nqs,577
|
3
|
+
linkplay/__version__.py,sha256=9pBH_sWelBMNY03FEugYdlVXfX9_b6TK-v2lLt7j0dY,23
|
4
|
+
linkplay/bridge.py,sha256=Ew9zKOL3bFlXSaxskPcF1ZFPYeZsc9O4gLJHz8K5C3o,12465
|
5
|
+
linkplay/consts.py,sha256=fck-MIcJ1MVwkWa5K1dTTWcleRuXs1EO7RY4MwJga8s,13402
|
6
|
+
linkplay/controller.py,sha256=IYoXvHh2zhrsRoRG7gwYFoWSIrL5Hl9hR7c2dhGPNX8,2484
|
7
|
+
linkplay/discovery.py,sha256=aEzN_94pKLmHKYIL7DxSW0FYRsaF2ruZe2bwXz0zf5U,4299
|
8
|
+
linkplay/endpoint.py,sha256=5Ybr54aroFVEZ6fnFYP41QAuSP7-J9qHYAzLod4S3KY,2459
|
9
|
+
linkplay/exceptions.py,sha256=tWJWHsKVkUEq3Yet1Z739IxcaQT8YamDeSp0tqHde9c,107
|
10
|
+
linkplay/utils.py,sha256=WVKdxITDymLCmKGqlD9Ieyb96qZ-QSC9oIe-KGW4IFU,7827
|
11
|
+
python_linkplay-0.0.12.dist-info/LICENSE,sha256=bgEtxMyjEHX_4uwaAY3GCFTm234D4AOZ5dM15sk26ms,1073
|
12
|
+
python_linkplay-0.0.12.dist-info/METADATA,sha256=I_YhOhrdEBBE5Ye5h9t6pSpoOaED_CL6yENZRvIv7DE,2988
|
13
|
+
python_linkplay-0.0.12.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
14
|
+
python_linkplay-0.0.12.dist-info/top_level.txt,sha256=CpSaOVPTzJf5TVIL7MrotSCR34gcIOQy-11l4zGmxxM,9
|
15
|
+
python_linkplay-0.0.12.dist-info/RECORD,,
|
@@ -1,15 +0,0 @@
|
|
1
|
-
linkplay/__init__.py,sha256=y9ZehEq-KhS3cwn-PUpwVSJGfDUx7e5wf_G6guODcTk,56
|
2
|
-
linkplay/__main__.py,sha256=Wcza80QaWfOaHjyJEfQYhB9kiPLE0NOqIj4zVWv2Nqs,577
|
3
|
-
linkplay/__version__.py,sha256=op0YgbBDjpD8XP_2_aEIvFkIRz9w0nlrOp56GUt0XxQ,23
|
4
|
-
linkplay/bridge.py,sha256=LXUc1zcRh1Hx1QauhlpA9da5k7f6h3KLfGRA1jAbTPU,11602
|
5
|
-
linkplay/consts.py,sha256=OGEj34YTiEWRBPjIebokDOVKOsa-DpZkCkUpThO8IIc,13068
|
6
|
-
linkplay/controller.py,sha256=IYoXvHh2zhrsRoRG7gwYFoWSIrL5Hl9hR7c2dhGPNX8,2484
|
7
|
-
linkplay/discovery.py,sha256=aEzN_94pKLmHKYIL7DxSW0FYRsaF2ruZe2bwXz0zf5U,4299
|
8
|
-
linkplay/endpoint.py,sha256=aWNiiU6h3gIWiNzcnavfA8IMZLufv9A8Cm5qphRpRvA,2158
|
9
|
-
linkplay/exceptions.py,sha256=tWJWHsKVkUEq3Yet1Z739IxcaQT8YamDeSp0tqHde9c,107
|
10
|
-
linkplay/utils.py,sha256=WVKdxITDymLCmKGqlD9Ieyb96qZ-QSC9oIe-KGW4IFU,7827
|
11
|
-
python_linkplay-0.0.10.dist-info/LICENSE,sha256=bgEtxMyjEHX_4uwaAY3GCFTm234D4AOZ5dM15sk26ms,1073
|
12
|
-
python_linkplay-0.0.10.dist-info/METADATA,sha256=ZzxS4W64XCLZXbDssg4YNhtbAmDkAgg-_aF_tY6SJYs,2988
|
13
|
-
python_linkplay-0.0.10.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
14
|
-
python_linkplay-0.0.10.dist-info/top_level.txt,sha256=CpSaOVPTzJf5TVIL7MrotSCR34gcIOQy-11l4zGmxxM,9
|
15
|
-
python_linkplay-0.0.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|