From: Marcel van der Veldt Date: Wed, 10 May 2023 20:58:21 +0000 (+0200) Subject: Fix some issues config/settings (#663) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=f9386004125cfa079fb082f32b355a9f65552bed;p=music-assistant-server.git Fix some issues config/settings (#663) * Fix for player settings * fix queue resume point * bump frontend to 20230510.0 --- diff --git a/music_assistant/common/models/config_entries.py b/music_assistant/common/models/config_entries.py index f16223d1..ab2bdd2d 100644 --- a/music_assistant/common/models/config_entries.py +++ b/music_assistant/common/models/config_entries.py @@ -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, diff --git a/music_assistant/constants.py b/music_assistant/constants.py index dc0597b9..b185d8f5 100755 --- a/music_assistant/constants.py +++ b/music_assistant/constants.py @@ -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" diff --git a/music_assistant/server/controllers/player_queues.py b/music_assistant/server/controllers/player_queues.py index 5c291137..7a90bc8d 100755 --- a/music_assistant/server/controllers/player_queues.py +++ b/music_assistant/server/controllers/player_queues.py @@ -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 diff --git a/music_assistant/server/helpers/audio.py b/music_assistant/server/helpers/audio.py index 84c14ab4..3b81eb2a 100644 --- a/music_assistant/server/helpers/audio.py +++ b/music_assistant/server/helpers/audio.py @@ -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 ) diff --git a/music_assistant/server/providers/sonos/__init__.py b/music_assistant/server/providers/sonos/__init__.py index b58cc66d..c98dc32f 100644 --- a/music_assistant/server/providers/sonos/__init__.py +++ b/music_assistant/server/providers/sonos/__init__.py @@ -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} diff --git a/pyproject.toml b/pyproject.toml index cf616fed..b754f573 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/requirements_all.txt b/requirements_all.txt index 6451064e..164edb89 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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