From: Marcel van der Veldt Date: Wed, 19 Apr 2023 08:58:46 +0000 (+0200) Subject: Various small bugfixes and improvements (#633) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=b98ca200d521e50778306f42be11de5a4c85d4f2;p=music-assistant-server.git Various small bugfixes and improvements (#633) * fix missing classes * fix logging * set active source only when playing * try to improve sonos discovery * add support for separate dark icons * bump frontend to 20230419.0 --- diff --git a/music_assistant/common/models/provider.py b/music_assistant/common/models/provider.py index a7b72848..59fb538e 100644 --- a/music_assistant/common/models/provider.py +++ b/music_assistant/common/models/provider.py @@ -40,6 +40,10 @@ class ProviderManifest(DataClassORJSONMixin): # if this attribute is omitted and an icon.svg or icon.png is found in the provider # folder, it will be read instead. icon: str | None = None + # icon_dark: optional separate dark icon + # if this attribute is omitted and an icon_dark.svg or icon_dark.png is found in the provider + # folder, it will be read instead. + icon_dark: str | None = None @classmethod async def parse(cls: "ProviderManifest", manifest_file: str) -> "ProviderManifest": diff --git a/music_assistant/common/models/queue_item.py b/music_assistant/common/models/queue_item.py index fe387174..bb73d34e 100644 --- a/music_assistant/common/models/queue_item.py +++ b/music_assistant/common/models/queue_item.py @@ -2,16 +2,13 @@ from __future__ import annotations from dataclasses import dataclass -from typing import TYPE_CHECKING, Any +from typing import Any from uuid import uuid4 from mashumaro import DataClassDictMixin from .enums import MediaType -from .media_items import ItemMapping, MediaItemImage, StreamDetails - -if TYPE_CHECKING: - from .media_items import Album, Radio, Track +from .media_items import Album, ItemMapping, MediaItemImage, Radio, StreamDetails, Track @dataclass diff --git a/music_assistant/server/controllers/config.py b/music_assistant/server/controllers/config.py index 5e9a8b3f..288c4e81 100644 --- a/music_assistant/server/controllers/config.py +++ b/music_assistant/server/controllers/config.py @@ -443,13 +443,12 @@ class ConfigController: _filename = os.path.join(self.mass.storage_path, filename) async with aiofiles.open(_filename, "r", encoding="utf-8") as _file: self._data = json_loads(await _file.read()) + LOGGER.debug("Loaded persistent settings from %s", filename) return except FileNotFoundError: pass except JSON_DECODE_EXCEPTIONS: # pylint: disable=catching-non-exception LOGGER.error("Error while reading persistent storage file %s", filename) - else: - LOGGER.debug("Loaded persistent settings from %s", filename) LOGGER.debug("Started with empty storage: No persistent storage file found.") async def _async_save(self): diff --git a/music_assistant/server/controllers/players.py b/music_assistant/server/controllers/players.py index dbcc2132..47dc136d 100755 --- a/music_assistant/server/controllers/players.py +++ b/music_assistant/server/controllers/players.py @@ -320,8 +320,8 @@ class PlayerController: player = self.get(player_id, True) if player.powered == powered: return - # send stop at power off - if not powered: + # stop player at power off + if not powered and player.state in (PlayerState.PLAYING, PlayerState.PAUSED): await self.cmd_stop(player_id) # unsync player at power off if not powered and player.synced_to is not None: @@ -495,7 +495,7 @@ class PlayerController: if group_player.powered: return group_player.player_id # guess source from player's current url - if player.current_url: + if player.current_url and player.state in (PlayerState.PLAYING, PlayerState.PAUSED): if self.mass.webserver.base_url in player.current_url: return player.player_id if ":" in player.current_url: diff --git a/music_assistant/server/providers/sonos/__init__.py b/music_assistant/server/providers/sonos/__init__.py index 55e2ddfb..b58cc66d 100644 --- a/music_assistant/server/providers/sonos/__init__.py +++ b/music_assistant/server/providers/sonos/__init__.py @@ -405,7 +405,9 @@ 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, 10) + discovered_devices: set[soco.SoCo] = await asyncio.to_thread( + soco.discover, 30, allow_network_scan=True + ) if discovered_devices is None: discovered_devices = set() new_device_ids = {item.uid for item in discovered_devices} diff --git a/music_assistant/server/server.py b/music_assistant/server/server.py index a6c01ca0..41374777 100644 --- a/music_assistant/server/server.py +++ b/music_assistant/server/server.py @@ -439,6 +439,13 @@ class MusicAssistant: if os.path.isfile(icon_path): provider_manifest.icon = await get_icon_string(icon_path) break + # check for dark_icon file + if not provider_manifest.icon_dark: + for icon_file in ("icon_dark.svg", "icon_dark.png"): + icon_path = os.path.join(dir_path, icon_file) + if os.path.isfile(icon_path): + provider_manifest.icon_dark = await get_icon_string(icon_path) + break self._available_providers[provider_manifest.domain] = provider_manifest LOGGER.debug("Loaded manifest for provider %s", dir_str) except Exception as exc: # pylint: disable=broad-except diff --git a/pyproject.toml b/pyproject.toml index 4a1c2eb5..f96a862c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ server = [ "python-slugify==8.0.1", "mashumaro==3.7", "memory-tempfile==2.2.3", - "music-assistant-frontend==20230414.0", + "music-assistant-frontend==20230419.0", "pillow==9.5.0", "unidecode==1.3.6", "xmltodict==0.13.0", diff --git a/requirements_all.txt b/requirements_all.txt index 307a7bcc..471de6b5 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -14,7 +14,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==20230414.0 +music-assistant-frontend==20230419.0 orjson==3.8.9 pillow==9.5.0 plexapi==4.13.4