tidal: allow audio quality switching after authentication (#2144)
authorJozef Kruszynski <60214390+jozefKruszynski@users.noreply.github.com>
Thu, 24 Apr 2025 22:29:16 +0000 (00:29 +0200)
committerGitHub <noreply@github.com>
Thu, 24 Apr 2025 22:29:16 +0000 (00:29 +0200)
music_assistant/providers/tidal/__init__.py

index a679d63b5ad5e3e3e1661511d0c8662f2040a650..70912b190b5ea8081b6775c9a02a0de59c1de4bf 100644 (file)
@@ -8,7 +8,6 @@ import json
 from collections.abc import Awaitable, Callable
 from contextlib import suppress
 from datetime import datetime
-from enum import StrEnum
 from typing import TYPE_CHECKING, Any, TypeVar, cast
 
 from aiohttp import ClientConnectionError, ClientResponse
@@ -101,13 +100,6 @@ DEFAULT_LIMIT = 50
 T = TypeVar("T")
 
 
-class TidalQualityEnum(StrEnum):
-    """Enum for Tidal Quality."""
-
-    HIGH_LOSSLESS = "LOSSLESS"  # "High - 16bit, 44.1kHz"
-    HI_RES = "HI_RES_LOSSLESS"  # "Max - Up to 24bit, 192kHz"
-
-
 async def setup(
     mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
 ) -> ProviderInstanceType:
@@ -180,13 +172,13 @@ async def get_config_entries(
             ConfigEntry(
                 key=CONF_QUALITY,
                 type=ConfigEntryType.STRING,
-                label=CONF_QUALITY,
-                required=True,
-                hidden=True,
-                value=cast("str", values.get(CONF_QUALITY) or TidalQualityEnum.HI_RES.value),
-                default_value=cast(
-                    "str", values.get(CONF_QUALITY) or TidalQualityEnum.HI_RES.value
-                ),
+                label="Quality setting for Tidal:",
+                description="High = 16bit 44.1kHz\n\nMax = Up to 24bit 192kHz",
+                options=[
+                    ConfigValueOption("High", "LOSSLESS"),
+                    ConfigValueOption("Max", "HI_RES_LOSSLESS"),
+                ],
+                default_value="HI_RES_LOSSLESS",
             ),
         )
     else:
@@ -196,10 +188,12 @@ async def get_config_entries(
                 type=ConfigEntryType.STRING,
                 label="Quality setting for Tidal:",
                 required=True,
-                description="HIGH_LOSSLESS = 16bit 44.1kHz, HI_RES = Up to 24bit 192kHz",
-                options=[ConfigValueOption(x.value, x.name) for x in TidalQualityEnum],
-                default_value=TidalQualityEnum.HI_RES.value,
-                value=cast("str", values.get(CONF_QUALITY)) if values else None,
+                description="High = 16bit 44.1kHz\n\nMax = Up to 24bit 192kHz",
+                options=[
+                    ConfigValueOption("High", "LOSSLESS"),
+                    ConfigValueOption("Max", "HI_RES_LOSSLESS"),
+                ],
+                default_value="HI_RES_LOSSLESS",
             ),
             ConfigEntry(
                 key=LABEL_START_PKCE_LOGIN,