Fix some issues config/settings (#663)
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 10 May 2023 20:58:21 +0000 (22:58 +0200)
committerGitHub <noreply@github.com>
Wed, 10 May 2023 20:58:21 +0000 (22:58 +0200)
* Fix for player settings

* fix queue resume point

* bump frontend to 20230510.0

music_assistant/common/models/config_entries.py
music_assistant/constants.py
music_assistant/server/controllers/player_queues.py
music_assistant/server/helpers/audio.py
music_assistant/server/providers/sonos/__init__.py
pyproject.toml
requirements_all.txt

index f16223d10ef6ae6f6bcb26c66b8aa4a3c7b684b6..ab2bdd2d2ac2ef9290a5f9ae4b6456f9d5e89d5d 100644 (file)
@@ -20,8 +20,8 @@ from music_assistant.constants import (
     CONF_LOG_LEVEL,
     CONF_OUTPUT_CHANNELS,
     CONF_OUTPUT_CODEC,
-    CONF_VOLUME_NORMALISATION,
-    CONF_VOLUME_NORMALISATION_TARGET,
+    CONF_VOLUME_NORMALIZATION,
+    CONF_VOLUME_NORMALIZATION_TARGET,
     SECURE_STRING_SUBSTITUTE,
 )
 
@@ -116,12 +116,14 @@ class ConfigEntry(DataClassDictMixin):
             if expected_type == int and isinstance(value, float):
                 self.value = int(value)
                 return self.value
-            if expected_type == int and isinstance(value, str) and value.isnumeric():
-                self.value = int(value)
-                return self.value
-            if expected_type == float and isinstance(value, str) and value.isnumeric():
-                self.value = float(value)
-                return self.value
+            for val_type in (int, float):
+                # convert int/float from string
+                if expected_type == val_type and isinstance(value, str):
+                    try:
+                        self.value = val_type(value)
+                        return self.value
+                    except ValueError:
+                        pass
             if self.type in UI_ONLY:
                 self.value = self.default_value
                 return self.value
@@ -327,8 +329,8 @@ CONF_ENTRY_OUTPUT_CHANNELS = ConfigEntry(
     advanced=True,
 )
 
-CONF_ENTRY_VOLUME_NORMALISATION = ConfigEntry(
-    key=CONF_VOLUME_NORMALISATION,
+CONF_ENTRY_VOLUME_NORMALIZATION = ConfigEntry(
+    key=CONF_VOLUME_NORMALIZATION,
     type=ConfigEntryType.BOOLEAN,
     label="Enable volume normalization (EBU-R128 based)",
     default_value=True,
@@ -336,14 +338,14 @@ CONF_ENTRY_VOLUME_NORMALISATION = ConfigEntry(
     "standard without affecting dynamic range",
 )
 
-CONF_ENTRY_VOLUME_NORMALISATION_TARGET = ConfigEntry(
-    key=CONF_VOLUME_NORMALISATION_TARGET,
+CONF_ENTRY_VOLUME_NORMALIZATION_TARGET = ConfigEntry(
+    key=CONF_VOLUME_NORMALIZATION_TARGET,
     type=ConfigEntryType.INTEGER,
     range=(-30, 0),
     default_value=-14,
-    label="Target level for volume normalisation",
+    label="Target level for volume normalization",
     description="Adjust average (perceived) loudness to this target level, " "default is -14 LUFS",
-    depends_on=CONF_VOLUME_NORMALISATION,
+    depends_on=CONF_VOLUME_NORMALIZATION,
     advanced=True,
 )
 
@@ -407,9 +409,9 @@ CONF_ENTRY_GROUPED_POWER_ON = ConfigEntry(
 )
 
 DEFAULT_PLAYER_CONFIG_ENTRIES = (
-    CONF_ENTRY_VOLUME_NORMALISATION,
+    CONF_ENTRY_VOLUME_NORMALIZATION,
     CONF_ENTRY_FLOW_MODE,
-    CONF_ENTRY_VOLUME_NORMALISATION_TARGET,
+    CONF_ENTRY_VOLUME_NORMALIZATION_TARGET,
     CONF_ENTRY_EQ_BASS,
     CONF_ENTRY_EQ_MID,
     CONF_ENTRY_EQ_TREBLE,
index dc0597b966ccde1c1e9647dc1c96ced512956155..b185d8f5cab004f19f773efe0be17197ce054cbe 100755 (executable)
@@ -35,8 +35,8 @@ CONF_PLAYERS: Final[str] = "players"
 CONF_PATH: Final[str] = "path"
 CONF_USERNAME: Final[str] = "username"
 CONF_PASSWORD: Final[str] = "password"
-CONF_VOLUME_NORMALISATION: Final[str] = "volume_normalisation"
-CONF_VOLUME_NORMALISATION_TARGET: Final[str] = "volume_normalisation_target"
+CONF_VOLUME_NORMALIZATION: Final[str] = "volume_normalization"
+CONF_VOLUME_NORMALIZATION_TARGET: Final[str] = "volume_normalization_target"
 CONF_MAX_SAMPLE_RATE: Final[str] = "max_sample_rate"
 CONF_EQ_BASS: Final[str] = "eq_bass"
 CONF_EQ_MID: Final[str] = "eq_mid"
index 5c291137d4842d8eaad0a18f6c8845b8caa59ee3..7a90bc8d3a9fc9f502f266d93ce5bd8d117a1e4b 100755 (executable)
@@ -443,10 +443,10 @@ class PlayerQueuesController:
             # track is already played for > 90% - skip to next
             resume_item = next_item
             resume_pos = 0
-        elif queue.current_index is not None and len(queue_items) > 0:
+        elif not resume_item and queue.current_index is not None and len(queue_items) > 0:
             resume_item = self.get_item(queue_id, queue.current_index)
             resume_pos = 0
-        elif queue.current_index is None and len(queue_items) > 0:
+        elif not resume_item and queue.current_index is None and len(queue_items) > 0:
             # items available in queue but no previous track, start at 0
             resume_item = self.get_item(queue_id, 0)
             resume_pos = 0
index 84c14ab41a721598b6dbb284428d3332c44326b9..3b81eb2ad0fbc1ca05388063aa3f936519687bf0 100644 (file)
@@ -18,8 +18,8 @@ from music_assistant.common.helpers.util import create_tempfile
 from music_assistant.common.models.errors import AudioError, MediaNotFoundError, MusicAssistantError
 from music_assistant.common.models.media_items import ContentType, MediaType, StreamDetails
 from music_assistant.constants import (
-    CONF_VOLUME_NORMALISATION,
-    CONF_VOLUME_NORMALISATION_TARGET,
+    CONF_VOLUME_NORMALIZATION,
+    CONF_VOLUME_NORMALIZATION_TARGET,
     ROOT_LOGGER_NAME,
 )
 from music_assistant.server.helpers.process import AsyncProcess, check_output
@@ -295,11 +295,11 @@ async def get_gain_correct(
 ) -> tuple[float | None, float | None]:
     """Get gain correction for given queue / track combination."""
     player_settings = mass.config.get_player_config(streamdetails.queue_id)
-    if not player_settings or not player_settings.get_value(CONF_VOLUME_NORMALISATION):
+    if not player_settings or not player_settings.get_value(CONF_VOLUME_NORMALIZATION):
         return (None, None)
     if streamdetails.gain_correct is not None:
         return (streamdetails.loudness, streamdetails.gain_correct)
-    target_gain = player_settings.get_value(CONF_VOLUME_NORMALISATION_TARGET)
+    target_gain = player_settings.get_value(CONF_VOLUME_NORMALIZATION_TARGET)
     track_loudness = await mass.music.get_track_loudness(
         streamdetails.item_id, streamdetails.provider
     )
index b58cc66d3beb488a3346ce26c0bc28830d0a9ecc..c98dc32f6a657337ce0dce872f3150dacb0e23fd 100644 (file)
@@ -405,9 +405,7 @@ class SonosPlayerProvider(PlayerProvider):
         try:
             self._discovery_running = True
             self.logger.debug("Sonos discovery started...")
-            discovered_devices: set[soco.SoCo] = await asyncio.to_thread(
-                soco.discover, 30, allow_network_scan=True
-            )
+            discovered_devices: set[soco.SoCo] = await asyncio.to_thread(soco.discover, 60)
             if discovered_devices is None:
                 discovered_devices = set()
             new_device_ids = {item.uid for item in discovered_devices}
index cf616fed55821eb3c1d7f3fcc813c7f0313de4a1..b754f5730c457a251611c3a642c8916711b1ee70 100644 (file)
@@ -36,7 +36,7 @@ server = [
   "python-slugify==8.0.1",
   "mashumaro==3.7",
   "memory-tempfile==2.2.3",
-  "music-assistant-frontend==20230420.0",
+  "music-assistant-frontend==20230510.0",
   "pillow==9.5.0",
   "unidecode==1.3.6",
   "xmltodict==0.13.0",
index 6451064e1e59d51045bb904fadfef5bcfa9d2fb9..164edb89dc3690058d706da993ec56989f77c08d 100644 (file)
@@ -18,7 +18,7 @@ git+https://github.com/jozefKruszynski/python-tidal.git@v0.7.1
 git+https://github.com/pytube/pytube.git@refs/pull/1501/head
 mashumaro==3.7
 memory-tempfile==2.2.3
-music-assistant-frontend==20230420.0
+music-assistant-frontend==20230510.0
 orjson==3.8.12
 pillow==9.5.0
 plexapi==4.13.4