python-linkplay 0.2.0__tar.gz → 0.2.1__tar.gz
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.
- {python_linkplay-0.2.0/src/python_linkplay.egg-info → python_linkplay-0.2.1}/PKG-INFO +1 -1
- python_linkplay-0.2.1/src/linkplay/__version__.py +1 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/bridge.py +40 -34
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/utils.py +33 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1/src/python_linkplay.egg-info}/PKG-INFO +1 -1
- python_linkplay-0.2.0/src/linkplay/__version__.py +0 -1
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/LICENSE +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/README.md +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/pyproject.toml +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/setup.cfg +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/setup.py +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/__init__.py +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/__main__.py +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/consts.py +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/controller.py +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/discovery.py +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/endpoint.py +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/exceptions.py +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/linkplay/manufacturers.py +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/python_linkplay.egg-info/SOURCES.txt +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/python_linkplay.egg-info/dependency_links.txt +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/python_linkplay.egg-info/not-zip-safe +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/python_linkplay.egg-info/requires.txt +0 -0
- {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/python_linkplay.egg-info/top_level.txt +0 -0
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            __version__ = '0.2.1'
         | 
| @@ -23,7 +23,11 @@ from linkplay.consts import ( | |
| 23 23 | 
             
            from linkplay.endpoint import LinkPlayEndpoint
         | 
| 24 24 | 
             
            from linkplay.exceptions import LinkPlayInvalidDataException
         | 
| 25 25 | 
             
            from linkplay.manufacturers import MANUFACTURER_WIIM, get_info_from_project
         | 
| 26 | 
            -
            from linkplay.utils import  | 
| 26 | 
            +
            from linkplay.utils import (
         | 
| 27 | 
            +
                equalizer_mode_from_number_mapping,
         | 
| 28 | 
            +
                equalizer_mode_to_number_mapping,
         | 
| 29 | 
            +
                fixup_player_properties,
         | 
| 30 | 
            +
            )
         | 
| 27 31 |  | 
| 28 32 |  | 
| 29 33 | 
             
            class LinkPlayDevice:
         | 
| @@ -117,10 +121,12 @@ class LinkPlayPlayer: | |
| 117 121 |  | 
| 118 122 | 
             
                bridge: LinkPlayBridge
         | 
| 119 123 | 
             
                properties: dict[PlayerAttribute, str]
         | 
| 124 | 
            +
                custom_properties: dict[PlayerAttribute, str]
         | 
| 120 125 |  | 
| 121 126 | 
             
                def __init__(self, bridge: LinkPlayBridge):
         | 
| 122 127 | 
             
                    self.bridge = bridge
         | 
| 123 128 | 
             
                    self.properties = dict.fromkeys(PlayerAttribute.__members__.values(), "")
         | 
| 129 | 
            +
                    self.custom_properties = dict.fromkeys(PlayerAttribute.__members__.values(), "")
         | 
| 124 130 |  | 
| 125 131 | 
             
                def to_dict(self):
         | 
| 126 132 | 
             
                    """Return the state of the LinkPlayPlayer."""
         | 
| @@ -188,38 +194,28 @@ class LinkPlayPlayer: | |
| 188 194 | 
             
                async def set_equalizer_mode(self, mode: EqualizerMode) -> None:
         | 
| 189 195 | 
             
                    """Set the equalizer mode."""
         | 
| 190 196 | 
             
                    if self.bridge.device.manufacturer == MANUFACTURER_WIIM:
         | 
| 191 | 
            -
                         | 
| 192 | 
            -
                        # and don't support the general equalizer mode command
         | 
| 193 | 
            -
                        if mode not in self.available_equalizer_modes:
         | 
| 194 | 
            -
                            raise ValueError(
         | 
| 195 | 
            -
                                f"Invalid equalizer mode {mode}. Allowed equalizer modes are {self.available_equalizer_modes}."
         | 
| 196 | 
            -
                            )
         | 
| 197 | 
            -
             | 
| 198 | 
            -
                        if mode == EqualizerMode.NONE:
         | 
| 199 | 
            -
                            await self.bridge.json_request(LinkPlayCommand.WIIM_EQUALIZER_OFF)
         | 
| 200 | 
            -
                        else:
         | 
| 201 | 
            -
                            await self.bridge.json_request(
         | 
| 202 | 
            -
                                LinkPlayCommand.WIIM_EQ_LOAD.format(mode)
         | 
| 203 | 
            -
                            )
         | 
| 204 | 
            -
                        # WiiM doesn't update the property after setting it
         | 
| 205 | 
            -
                        self.properties[PlayerAttribute.EQUALIZER_MODE] = mode
         | 
| 197 | 
            +
                        await self._set_wiim_equalizer_mode(mode)
         | 
| 206 198 | 
             
                    else:
         | 
| 207 199 | 
             
                        await self._set_normal_equalizer_mode(mode)
         | 
| 208 200 |  | 
| 201 | 
            +
                async def _set_wiim_equalizer_mode(self, mode: EqualizerMode) -> None:
         | 
| 202 | 
            +
                    # WiiM devices have a different equalizer mode handling
         | 
| 203 | 
            +
                    # and don't support the general equalizer mode command
         | 
| 204 | 
            +
                    if mode not in self.available_equalizer_modes:
         | 
| 205 | 
            +
                        raise ValueError(
         | 
| 206 | 
            +
                            f"Invalid equalizer mode {mode}. Allowed equalizer modes are {self.available_equalizer_modes}."
         | 
| 207 | 
            +
                        )
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                    if mode == EqualizerMode.NONE:
         | 
| 210 | 
            +
                        await self.bridge.json_request(LinkPlayCommand.WIIM_EQUALIZER_OFF)
         | 
| 211 | 
            +
                    else:
         | 
| 212 | 
            +
                        await self.bridge.json_request(LinkPlayCommand.WIIM_EQ_LOAD.format(mode))
         | 
| 213 | 
            +
                    # WiiM doesn't update the property after setting it
         | 
| 214 | 
            +
                    self.custom_properties[PlayerAttribute.EQUALIZER_MODE] = mode
         | 
| 215 | 
            +
             | 
| 209 216 | 
             
                async def _set_normal_equalizer_mode(self, mode: EqualizerMode) -> None:
         | 
| 210 217 | 
             
                    """Set the equalizer mode."""
         | 
| 211 | 
            -
                    equalizer_mode_as_number =  | 
| 212 | 
            -
                    match mode:
         | 
| 213 | 
            -
                        case EqualizerMode.NONE:
         | 
| 214 | 
            -
                            equalizer_mode_as_number = "0"
         | 
| 215 | 
            -
                        case EqualizerMode.CLASSIC:
         | 
| 216 | 
            -
                            equalizer_mode_as_number = "1"
         | 
| 217 | 
            -
                        case EqualizerMode.POP:
         | 
| 218 | 
            -
                            equalizer_mode_as_number = "2"
         | 
| 219 | 
            -
                        case EqualizerMode.JAZZ:
         | 
| 220 | 
            -
                            equalizer_mode_as_number = "3"
         | 
| 221 | 
            -
                        case EqualizerMode.VOCAL:
         | 
| 222 | 
            -
                            equalizer_mode_as_number = "4"
         | 
| 218 | 
            +
                    equalizer_mode_as_number = equalizer_mode_to_number_mapping(mode)
         | 
| 223 219 | 
             
                    if equalizer_mode_as_number is None:
         | 
| 224 220 | 
             
                        raise ValueError(
         | 
| 225 221 | 
             
                            f"Invalid equalizer mode {mode}. Allowed equalizer modes are {self.available_equalizer_modes}."
         | 
| @@ -317,14 +313,24 @@ class LinkPlayPlayer: | |
| 317 313 | 
             
                @property
         | 
| 318 314 | 
             
                def equalizer_mode(self) -> EqualizerMode:
         | 
| 319 315 | 
             
                    """Returns the current equalizer mode."""
         | 
| 320 | 
            -
                     | 
| 316 | 
            +
                    try:
         | 
| 317 | 
            +
                        if self.bridge.device.manufacturer == MANUFACTURER_WIIM:
         | 
| 318 | 
            +
                            # WiiM devices have a different equalizer mode handling
         | 
| 319 | 
            +
                            # and will never ever return what equalizer mode they are in
         | 
| 320 | 
            +
                            return EqualizerMode(
         | 
| 321 | 
            +
                                self.custom_properties.get(
         | 
| 322 | 
            +
                                    PlayerAttribute.EQUALIZER_MODE, EqualizerMode.NONE
         | 
| 323 | 
            +
                                )
         | 
| 324 | 
            +
                            )
         | 
| 325 | 
            +
             | 
| 321 326 | 
             
                        return EqualizerMode(
         | 
| 322 | 
            -
                             | 
| 327 | 
            +
                            equalizer_mode_from_number_mapping(
         | 
| 328 | 
            +
                                self.properties.get(PlayerAttribute.EQUALIZER_MODE)
         | 
| 329 | 
            +
                            )
         | 
| 330 | 
            +
                            or EqualizerMode.NONE
         | 
| 323 331 | 
             
                        )
         | 
| 324 | 
            -
             | 
| 325 | 
            -
             | 
| 326 | 
            -
                        self.properties.get(PlayerAttribute.EQUALIZER_MODE, EqualizerMode.CLASSIC)
         | 
| 327 | 
            -
                    )
         | 
| 332 | 
            +
                    except ValueError:
         | 
| 333 | 
            +
                        return EqualizerMode.NONE
         | 
| 328 334 |  | 
| 329 335 | 
             
                @property
         | 
| 330 336 | 
             
                def available_equalizer_modes(self) -> list[EqualizerMode]:
         | 
| @@ -19,6 +19,7 @@ from linkplay.consts import ( | |
| 19 19 | 
             
                API_TIMEOUT,
         | 
| 20 20 | 
             
                MTLS_CERTIFICATE_CONTENTS,
         | 
| 21 21 | 
             
                TCP_MESSAGE_LENGTH,
         | 
| 22 | 
            +
                EqualizerMode,
         | 
| 22 23 | 
             
                PlayerAttribute,
         | 
| 23 24 | 
             
                PlayingStatus,
         | 
| 24 25 | 
             
            )
         | 
| @@ -241,3 +242,35 @@ def fixup_player_properties( | |
| 241 242 | 
             
                    properties[PlayerAttribute.PLAYING_STATUS] = PlayingStatus.STOPPED
         | 
| 242 243 |  | 
| 243 244 | 
             
                return properties
         | 
| 245 | 
            +
             | 
| 246 | 
            +
             | 
| 247 | 
            +
            def equalizer_mode_to_number_mapping(equalizer_mode: EqualizerMode) -> str | None:
         | 
| 248 | 
            +
                """Converts EqualizerMode to a number mapping."""
         | 
| 249 | 
            +
                match equalizer_mode:
         | 
| 250 | 
            +
                    case EqualizerMode.NONE:
         | 
| 251 | 
            +
                        return "0"
         | 
| 252 | 
            +
                    case EqualizerMode.CLASSIC:
         | 
| 253 | 
            +
                        return "1"
         | 
| 254 | 
            +
                    case EqualizerMode.POP:
         | 
| 255 | 
            +
                        return "2"
         | 
| 256 | 
            +
                    case EqualizerMode.JAZZ:
         | 
| 257 | 
            +
                        return "3"
         | 
| 258 | 
            +
                    case EqualizerMode.VOCAL:
         | 
| 259 | 
            +
                        return "4"
         | 
| 260 | 
            +
                return None
         | 
| 261 | 
            +
             | 
| 262 | 
            +
             | 
| 263 | 
            +
            def equalizer_mode_from_number_mapping(value: str | None) -> EqualizerMode | None:
         | 
| 264 | 
            +
                """Converts a number mapping to EqualizerMode."""
         | 
| 265 | 
            +
                match value:
         | 
| 266 | 
            +
                    case "0":
         | 
| 267 | 
            +
                        return EqualizerMode.NONE
         | 
| 268 | 
            +
                    case "1":
         | 
| 269 | 
            +
                        return EqualizerMode.CLASSIC
         | 
| 270 | 
            +
                    case "2":
         | 
| 271 | 
            +
                        return EqualizerMode.POP
         | 
| 272 | 
            +
                    case "3":
         | 
| 273 | 
            +
                        return EqualizerMode.JAZZ
         | 
| 274 | 
            +
                    case "4":
         | 
| 275 | 
            +
                        return EqualizerMode.VOCAL
         | 
| 276 | 
            +
                return None
         | 
| @@ -1 +0,0 @@ | |
| 1 | 
            -
            __version__ = '0.2.0'
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
    
        {python_linkplay-0.2.0 → python_linkplay-0.2.1}/src/python_linkplay.egg-info/dependency_links.txt
    RENAMED
    
    | 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |