python-linkplay 0.2.3__py3-none-any.whl → 0.2.5__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 CHANGED
@@ -1 +1 @@
1
- __version__ = '0.2.3'
1
+ __version__ = '0.2.5'
linkplay/bridge.py CHANGED
@@ -7,12 +7,15 @@ from linkplay.consts import (
7
7
  INPUT_MODE_MAP,
8
8
  LOGGER,
9
9
  PLAY_MODE_SEND_MAP,
10
+ AudioOutputHwMode,
10
11
  ChannelType,
11
12
  DeviceAttribute,
12
13
  EqualizerMode,
13
14
  InputMode,
14
15
  LinkPlayCommand,
15
16
  LoopMode,
17
+ MetaInfo,
18
+ MetaInfoMetaData,
16
19
  MultiroomAttribute,
17
20
  MuteMode,
18
21
  PlayerAttribute,
@@ -128,6 +131,7 @@ class LinkPlayPlayer:
128
131
  bridge: LinkPlayBridge
129
132
  properties: dict[PlayerAttribute, str]
130
133
  custom_properties: dict[PlayerAttribute, str]
134
+ metainfo: dict[MetaInfo, dict[MetaInfoMetaData, str]]
131
135
 
132
136
  previous_playing_mode: PlayingMode | None = None
133
137
 
@@ -135,6 +139,7 @@ class LinkPlayPlayer:
135
139
  self.bridge = bridge
136
140
  self.properties = dict.fromkeys(PlayerAttribute.__members__.values(), "")
137
141
  self.custom_properties = dict.fromkeys(PlayerAttribute.__members__.values(), "")
142
+ self.metainfo = dict.fromkeys(MetaInfo.__members__.values(), {})
138
143
 
139
144
  def to_dict(self):
140
145
  """Return the state of the LinkPlayPlayer."""
@@ -147,6 +152,18 @@ class LinkPlayPlayer:
147
152
  ) # type: ignore[assignment]
148
153
 
149
154
  self.properties = fixup_player_properties(properties)
155
+ if self.bridge.device.manufacturer == MANUFACTURER_WIIM:
156
+ try:
157
+ self.metainfo: dict[
158
+ MetaInfo, dict[MetaInfoMetaData, str]
159
+ ] = await self.bridge.json_request(LinkPlayCommand.META_INFO) # type: ignore[assignment]
160
+ except LinkPlayInvalidDataException as exc:
161
+ if getattr(exc, "data", None) == "Failed":
162
+ self.metainfo = {}
163
+ else:
164
+ raise
165
+ else:
166
+ self.metainfo = {}
150
167
 
151
168
  # handle multiroom changes
152
169
  if self.bridge.device.controller is not None and (
@@ -277,6 +294,14 @@ class LinkPlayPlayer:
277
294
  ):
278
295
  await self.bridge.request(LinkPlayCommand.SEEK.format(position))
279
296
 
297
+ async def set_audio_output_hw_mode(self, mode: AudioOutputHwMode) -> None:
298
+ """Set the audio hardware output."""
299
+ await self.bridge.request(LinkPlayCommand.AUDIO_OUTPUT_HW_MODE_SET.format(mode))
300
+
301
+ async def get_audio_output_hw_mode(self) -> None:
302
+ """Get the audio hardware output."""
303
+ await self.bridge.json_request(LinkPlayCommand.AUDIO_OUTPUT_HW_MODE)
304
+
280
305
  @property
281
306
  def muted(self) -> bool:
282
307
  """Returns if the player is muted."""
@@ -300,6 +325,13 @@ class LinkPlayPlayer:
300
325
  """Returns if the currently playing album."""
301
326
  return self.properties.get(PlayerAttribute.ALBUM, "")
302
327
 
328
+ @property
329
+ def album_art(self) -> str:
330
+ """Returns the url to the album art."""
331
+ return self.metainfo.get(MetaInfo.METADATA, {}).get(
332
+ MetaInfoMetaData.ALBUM_ART, ""
333
+ )
334
+
303
335
  @property
304
336
  def volume(self) -> int:
305
337
  """Returns the player volume, expressed in %."""
linkplay/consts.py CHANGED
@@ -100,6 +100,9 @@ class LinkPlayCommand(StrEnum):
100
100
  PLAY_PRESET = "MCUKeyShortClick:{}"
101
101
  TIMESYNC = "timeSync:{}"
102
102
  WIIM_EQ_LOAD = "EQLoad:{}"
103
+ META_INFO = "getMetaInfo"
104
+ AUDIO_OUTPUT_HW_MODE_SET = "setAudioOutputHardwareMode:{}"
105
+ AUDIO_OUTPUT_HW_MODE = "getNewAudioOutputHardwareMode"
103
106
 
104
107
 
105
108
  class LinkPlayTcpUartCommand(StrEnum):
@@ -470,3 +473,50 @@ class MultiroomAttribute(StrEnum):
470
473
 
471
474
  def __repr__(self):
472
475
  return self.value
476
+
477
+
478
+ class MetaInfo(StrEnum):
479
+ METADATA = "metaData"
480
+
481
+ def __str__(self):
482
+ return self.value
483
+
484
+ def __repr__(self):
485
+ return self.value
486
+
487
+
488
+ class MetaInfoMetaData(StrEnum):
489
+ """Defines the metadata within the metainfo."""
490
+
491
+ ALBUM_TITLE = "album"
492
+ TRACK_TITLE = "title"
493
+ TRACK_SUBTITLE = "subtitle"
494
+ ALBUM_ART = "albumArtURI"
495
+ SAMPLE_RATE = "sampleRate"
496
+ BIT_DEPTH = "bitDepth"
497
+ BIT_RATE = "bitRate"
498
+ TRACK_ID = "trackId"
499
+
500
+ def __str__(self):
501
+ return self.value
502
+
503
+ def __repr__(self):
504
+ return self.value
505
+
506
+
507
+ class AudioOutputHwMode(StrEnum):
508
+ """Defines a output mode for the hardware."""
509
+
510
+ OPTICAL = "1"
511
+ LINE_OUT = "2"
512
+ COAXIAL = "3"
513
+ HEADPHONES = "4"
514
+
515
+
516
+ # Map between a play mode and how to activate the play mode
517
+ AUDIO_OUTPUT_HW_MODE_MAP: dict[AudioOutputHwMode, str] = { # case sensitive!
518
+ AudioOutputHwMode.OPTICAL: "optical",
519
+ AudioOutputHwMode.LINE_OUT: "line-out",
520
+ AudioOutputHwMode.COAXIAL: "co-axial",
521
+ AudioOutputHwMode.HEADPHONES: "headphones",
522
+ }
linkplay/exceptions.py CHANGED
@@ -7,4 +7,6 @@ class LinkPlayRequestException(LinkPlayException):
7
7
 
8
8
 
9
9
  class LinkPlayInvalidDataException(LinkPlayException):
10
- pass
10
+ def __init__(self, message: str = "Invalid data received", data: str | None = None):
11
+ super().__init__(message)
12
+ self.data = data
linkplay/utils.py CHANGED
@@ -82,7 +82,7 @@ async def session_call_api_json(
82
82
  except json.JSONDecodeError as jsonexc:
83
83
  url = API_ENDPOINT.format(endpoint, command)
84
84
  raise LinkPlayInvalidDataException(
85
- f"Unexpected JSON ({result}) received from '{url}'"
85
+ message=f"Unexpected JSON ({result}) received from '{url}'", data=result
86
86
  ) from jsonexc
87
87
 
88
88
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_linkplay
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: A Python Library for Seamless LinkPlay Device Control
5
5
  Author: Velleman Group nv
6
6
  License: MIT
@@ -48,16 +48,18 @@ Welcome to python-linkplay, a powerful and user-friendly Python library designed
48
48
  4. Metadata Retrieval: Retrieve essential metadata such as track information, artist details, and album data, enabling you to enhance the user interface and display relevant information in your applications.
49
49
 
50
50
  ## LinkPlay API documentation
51
-
52
- - https://github.com/n4archive/LinkPlayAPI
53
- - https://github.com/nagyrobi/home-assistant-custom-components-linkplay
54
- - https://github.com/ramikg/linkplay-cli
55
51
  - https://developer.arylic.com/httpapi/
56
52
  - http://airscope-audio.net/core2/pdf/airscope-module-http.pdf
57
53
  - https://www.wiimhome.com/pdf/HTTP%20API%20for%20WiiM%20Mini.pdf
58
54
  - https://www.wiimhome.com/pdf/HTTP%20API%20for%20WiiM%20Products.pdf
55
+
56
+ ## LinkPlay references
57
+ - https://github.com/n4archive/LinkPlayAPI
58
+ - https://github.com/nagyrobi/home-assistant-custom-components-linkplay
59
+ - https://github.com/ramikg/linkplay-cli
59
60
  - https://github.com/DanBrezeanu/wiim-extended-http-api
60
61
  - https://github.com/cvdlinden/wiim-httpapi
62
+ - https://community.openhab.org/t/linkplay-binding/161995
61
63
 
62
64
  ## Multiroom
63
65
 
@@ -0,0 +1,16 @@
1
+ linkplay/__init__.py,sha256=y9ZehEq-KhS3cwn-PUpwVSJGfDUx7e5wf_G6guODcTk,56
2
+ linkplay/__main__.py,sha256=Wcza80QaWfOaHjyJEfQYhB9kiPLE0NOqIj4zVWv2Nqs,577
3
+ linkplay/__version__.py,sha256=8f4ummWTPl6PtdE9DzSUgZhPjGioA_NDC-hDpqzB9qI,22
4
+ linkplay/bridge.py,sha256=IGohfJbBNa4C9cgva--Uhq5iMz4eRnljLbx-SqlsYd8,21582
5
+ linkplay/consts.py,sha256=vKlEZvo7-OIjHziimtZ3t4VkPZBoJc--Qj-7gHigxWk,15441
6
+ linkplay/controller.py,sha256=U370dMVl-E7iIhDC1wWmsrnFcdrWso84K0vkImsgCTo,4430
7
+ linkplay/discovery.py,sha256=NnkO9gknp3Cyff7830zBu1LwyhkkWCdhDbEDbAwF8D8,4610
8
+ linkplay/endpoint.py,sha256=_gelW0cDWt0SC8EApwaKIVh_YJIMNiOkfrLR_RYW7aM,2677
9
+ linkplay/exceptions.py,sha256=UHcV0Yok0hdM0MYgHRwTWnMJ612Ts0iJvMFHX-IxmNo,312
10
+ linkplay/manufacturers.py,sha256=oddlZTbtrCBVCcy5adbXk0bhBOXEcmC6U5-a7QShLHY,3906
11
+ linkplay/utils.py,sha256=fZHGnUM4XFrQ7MM6guHhaEmxJbVlwilbwoZXvXwSfMs,9480
12
+ python_linkplay-0.2.5.dist-info/licenses/LICENSE,sha256=bgEtxMyjEHX_4uwaAY3GCFTm234D4AOZ5dM15sk26ms,1073
13
+ python_linkplay-0.2.5.dist-info/METADATA,sha256=XFBM5m--r4RlIx-EkXh1MBFjxUoLelu7Cks9E2V3CaY,3260
14
+ python_linkplay-0.2.5.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
15
+ python_linkplay-0.2.5.dist-info/top_level.txt,sha256=CpSaOVPTzJf5TVIL7MrotSCR34gcIOQy-11l4zGmxxM,9
16
+ python_linkplay-0.2.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,16 +0,0 @@
1
- linkplay/__init__.py,sha256=y9ZehEq-KhS3cwn-PUpwVSJGfDUx7e5wf_G6guODcTk,56
2
- linkplay/__main__.py,sha256=Wcza80QaWfOaHjyJEfQYhB9kiPLE0NOqIj4zVWv2Nqs,577
3
- linkplay/__version__.py,sha256=XtWUl6HPylv5jZLd2KkgtPptuzuda93kC2REmOrF-Cs,22
4
- linkplay/bridge.py,sha256=m_1E71dP5sftvA4ahmRvDsNrYDHXGV9CpOynuv2v29I,20262
5
- linkplay/consts.py,sha256=3yUX_a_wOjpVLUPK5ogSCEOwgVJs-TIPb8LPo4Ds1Ic,14242
6
- linkplay/controller.py,sha256=U370dMVl-E7iIhDC1wWmsrnFcdrWso84K0vkImsgCTo,4430
7
- linkplay/discovery.py,sha256=NnkO9gknp3Cyff7830zBu1LwyhkkWCdhDbEDbAwF8D8,4610
8
- linkplay/endpoint.py,sha256=_gelW0cDWt0SC8EApwaKIVh_YJIMNiOkfrLR_RYW7aM,2677
9
- linkplay/exceptions.py,sha256=Kow13uJPSL4y6rXMnkcl_Yp9wH1weOyKw_knd0p-Exc,173
10
- linkplay/manufacturers.py,sha256=oddlZTbtrCBVCcy5adbXk0bhBOXEcmC6U5-a7QShLHY,3906
11
- linkplay/utils.py,sha256=U6hy5KKUzeEc3RMZigTJBynT-ddNfW8KIIMHaydZGQc,9459
12
- python_linkplay-0.2.3.dist-info/licenses/LICENSE,sha256=bgEtxMyjEHX_4uwaAY3GCFTm234D4AOZ5dM15sk26ms,1073
13
- python_linkplay-0.2.3.dist-info/METADATA,sha256=Y6N8RNsgHABjHRGztEuT_Gsbv4DP2u8K-Bsce10FO7E,3179
14
- python_linkplay-0.2.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
15
- python_linkplay-0.2.3.dist-info/top_level.txt,sha256=CpSaOVPTzJf5TVIL7MrotSCR34gcIOQy-11l4zGmxxM,9
16
- python_linkplay-0.2.3.dist-info/RECORD,,