python-linkplay 0.0.1__py3-none-any.whl → 0.0.2__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/consts.py +1 -0
- linkplay/discovery.py +29 -6
- linkplay/utils.py +4 -1
- {python_linkplay-0.0.1.dist-info → python_linkplay-0.0.2.dist-info}/METADATA +1 -1
- python_linkplay-0.0.2.dist-info/RECORD +13 -0
- python_linkplay-0.0.1.dist-info/RECORD +0 -13
- {python_linkplay-0.0.1.dist-info → python_linkplay-0.0.2.dist-info}/LICENSE +0 -0
- {python_linkplay-0.0.1.dist-info → python_linkplay-0.0.2.dist-info}/WHEEL +0 -0
- {python_linkplay-0.0.1.dist-info → python_linkplay-0.0.2.dist-info}/top_level.txt +0 -0
linkplay/__version__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.0.
|
1
|
+
__version__ = '0.0.2'
|
linkplay/consts.py
CHANGED
linkplay/discovery.py
CHANGED
@@ -23,7 +23,7 @@ async def linkplay_factory_bridge(ip_address: str, session: ClientSession) -> Li
|
|
23
23
|
|
24
24
|
async def discover_linkplay_bridges(session: ClientSession) -> list[LinkPlayBridge]:
|
25
25
|
"""Attempts to discover LinkPlay devices on the local network."""
|
26
|
-
|
26
|
+
bridges: dict[str, LinkPlayBridge] = {}
|
27
27
|
|
28
28
|
async def add_linkplay_device_to_list(upnp_device: CaseInsensitiveDict):
|
29
29
|
ip_address: str | None = upnp_device.get('_host')
|
@@ -32,19 +32,27 @@ async def discover_linkplay_bridges(session: ClientSession) -> list[LinkPlayBrid
|
|
32
32
|
return
|
33
33
|
|
34
34
|
if bridge := await linkplay_factory_bridge(ip_address, session):
|
35
|
-
|
35
|
+
bridges[bridge.device.uuid] = bridge
|
36
36
|
|
37
37
|
await async_search(
|
38
38
|
search_target=UPNP_DEVICE_TYPE,
|
39
39
|
async_callback=add_linkplay_device_to_list
|
40
40
|
)
|
41
41
|
|
42
|
-
|
42
|
+
# Discover additional bridges through grouped multirooms
|
43
|
+
multiroom_discovered_bridges: dict[str, LinkPlayBridge] = {}
|
44
|
+
for bridge in bridges.values():
|
45
|
+
for new_bridge in await discover_bridges_through_multiroom(bridge, session):
|
46
|
+
multiroom_discovered_bridges[new_bridge.device.uuid] = new_bridge
|
47
|
+
|
48
|
+
bridges = bridges | multiroom_discovered_bridges
|
49
|
+
return list(bridges.values())
|
43
50
|
|
44
51
|
|
45
52
|
async def discover_multirooms(bridges: list[LinkPlayBridge]) -> list[LinkPlayMultiroom]:
|
46
53
|
"""Discovers multirooms through the list of provided bridges."""
|
47
54
|
multirooms: list[LinkPlayMultiroom] = []
|
55
|
+
bridges_dict: dict[str, LinkPlayBridge] = {bridge.device.uuid: bridge for bridge in bridges}
|
48
56
|
|
49
57
|
for bridge in bridges:
|
50
58
|
properties: dict[Any, Any] = await bridge.json_request(LinkPlayCommand.MULTIROOM_LIST)
|
@@ -54,10 +62,25 @@ async def discover_multirooms(bridges: list[LinkPlayBridge]) -> list[LinkPlayMul
|
|
54
62
|
|
55
63
|
followers: list[LinkPlayBridge] = []
|
56
64
|
for follower in properties[MultiroomAttribute.FOLLOWER_LIST]:
|
57
|
-
|
58
|
-
|
59
|
-
followers.append(follower_bridge)
|
65
|
+
if follower[MultiroomAttribute.UUID] in bridges_dict:
|
66
|
+
followers.append(bridges_dict[follower[MultiroomAttribute.UUID]])
|
60
67
|
|
61
68
|
multirooms.append(LinkPlayMultiroom(bridge, followers))
|
62
69
|
|
63
70
|
return multirooms
|
71
|
+
|
72
|
+
|
73
|
+
async def discover_bridges_through_multiroom(bridge: LinkPlayBridge,
|
74
|
+
session: ClientSession) -> list[LinkPlayBridge]:
|
75
|
+
"""Discovers bridges through the multiroom of the provided bridge."""
|
76
|
+
properties: dict[Any, Any] = await bridge.json_request(LinkPlayCommand.MULTIROOM_LIST)
|
77
|
+
|
78
|
+
if int(properties[MultiroomAttribute.NUM_FOLLOWERS]) == 0:
|
79
|
+
return []
|
80
|
+
|
81
|
+
followers: list[LinkPlayBridge] = []
|
82
|
+
for follower in properties[MultiroomAttribute.FOLLOWER_LIST]:
|
83
|
+
if new_bridge := await linkplay_factory_bridge(follower[MultiroomAttribute.IP], session):
|
84
|
+
followers.append(new_bridge)
|
85
|
+
|
86
|
+
return followers
|
linkplay/utils.py
CHANGED
@@ -56,4 +56,7 @@ async def session_call_api_ok(endpoint: str, session: ClientSession, command: st
|
|
56
56
|
|
57
57
|
def decode_hexstr(hexstr: str) -> str:
|
58
58
|
"""Decode a hex string."""
|
59
|
-
|
59
|
+
try:
|
60
|
+
return bytes.fromhex(hexstr).decode("utf-8")
|
61
|
+
except ValueError:
|
62
|
+
return hexstr
|
@@ -0,0 +1,13 @@
|
|
1
|
+
linkplay/__init__.py,sha256=y9ZehEq-KhS3cwn-PUpwVSJGfDUx7e5wf_G6guODcTk,56
|
2
|
+
linkplay/__main__.py,sha256=AiwpQKJIV9HrSqj0qU-a8MKE-AUjbfTrQ6st45U78rE,382
|
3
|
+
linkplay/__version__.py,sha256=miSsqPy2PFJ18TW9kocQJLcv4HFpkfQhcTzgAO-GTVE,22
|
4
|
+
linkplay/bridge.py,sha256=l5Vvtp2SHF2FYMa67Yf-daRGsErMRXB1GMPzHhwwG6k,10344
|
5
|
+
linkplay/consts.py,sha256=KIBGrRQqxd1B4kRO0Vl0e5-UzbMLzJGC_ECohzkSRwQ,7750
|
6
|
+
linkplay/discovery.py,sha256=l4vRkkFYwdD8iqbSUHGZ16yBV8RqylkhBNL2zAqXVP0,3428
|
7
|
+
linkplay/exceptions.py,sha256=tWJWHsKVkUEq3Yet1Z739IxcaQT8YamDeSp0tqHde9c,107
|
8
|
+
linkplay/utils.py,sha256=E_SjIyeK76ishhwuU24m28y1FDAMEj1QbRNt-aHIMdA,2137
|
9
|
+
python_linkplay-0.0.2.dist-info/LICENSE,sha256=bgEtxMyjEHX_4uwaAY3GCFTm234D4AOZ5dM15sk26ms,1073
|
10
|
+
python_linkplay-0.0.2.dist-info/METADATA,sha256=esFb5Hu0jcGykawjsfEqJk7YpQxU4paUQhwOuCg6eBU,2859
|
11
|
+
python_linkplay-0.0.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
12
|
+
python_linkplay-0.0.2.dist-info/top_level.txt,sha256=CpSaOVPTzJf5TVIL7MrotSCR34gcIOQy-11l4zGmxxM,9
|
13
|
+
python_linkplay-0.0.2.dist-info/RECORD,,
|
@@ -1,13 +0,0 @@
|
|
1
|
-
linkplay/__init__.py,sha256=y9ZehEq-KhS3cwn-PUpwVSJGfDUx7e5wf_G6guODcTk,56
|
2
|
-
linkplay/__main__.py,sha256=AiwpQKJIV9HrSqj0qU-a8MKE-AUjbfTrQ6st45U78rE,382
|
3
|
-
linkplay/__version__.py,sha256=DsAHdxLC16H2VjdFOU5tBx2xT9VnNQ-XbTS24fRCa_w,22
|
4
|
-
linkplay/bridge.py,sha256=l5Vvtp2SHF2FYMa67Yf-daRGsErMRXB1GMPzHhwwG6k,10344
|
5
|
-
linkplay/consts.py,sha256=XpRJaPmz39EKFAZrgZEJRloL5lEI3p8jLPgrEJHgbjk,7736
|
6
|
-
linkplay/discovery.py,sha256=wmF7fsCd4htr7zHfDRh9z0J2cu1OjK50ZQaBfg3WlaU,2303
|
7
|
-
linkplay/exceptions.py,sha256=tWJWHsKVkUEq3Yet1Z739IxcaQT8YamDeSp0tqHde9c,107
|
8
|
-
linkplay/utils.py,sha256=L8P7n1JtI0Q62fHV2TC5K03TuPQXesSikXLVje6Av-E,2079
|
9
|
-
python_linkplay-0.0.1.dist-info/LICENSE,sha256=bgEtxMyjEHX_4uwaAY3GCFTm234D4AOZ5dM15sk26ms,1073
|
10
|
-
python_linkplay-0.0.1.dist-info/METADATA,sha256=-JpSNww6wpyDmpWHdQ-fAZXYBP4cCbPPUpSQCxh6sg0,2859
|
11
|
-
python_linkplay-0.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
12
|
-
python_linkplay-0.0.1.dist-info/top_level.txt,sha256=CpSaOVPTzJf5TVIL7MrotSCR34gcIOQy-11l4zGmxxM,9
|
13
|
-
python_linkplay-0.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|