From cec5e7f7c55fbb18185c0e72c93492b00b574bf1 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sat, 2 Nov 2024 18:09:16 +0100 Subject: [PATCH] Fix: leftover issues after repo split up --- music_assistant/controllers/config.py | 6 ++-- music_assistant/controllers/media/albums.py | 12 ++------ music_assistant/controllers/media/artists.py | 12 ++------ .../controllers/media/playlists.py | 2 +- music_assistant/controllers/metadata.py | 2 +- music_assistant/controllers/music.py | 4 +-- music_assistant/controllers/streams.py | 8 ++---- music_assistant/helpers/audio.py | 6 ++-- music_assistant/helpers/ffmpeg.py | 7 +++-- music_assistant/helpers/global_cache.py | 28 ------------------- music_assistant/helpers/uri.py | 4 +++ music_assistant/helpers/util.py | 2 +- music_assistant/mass.py | 2 +- music_assistant/models/player_provider.py | 12 ++++---- music_assistant/providers/airplay/provider.py | 28 ++++++++----------- .../providers/apple_music/__init__.py | 13 ++++++--- .../providers/bluesound/__init__.py | 20 ++++++------- music_assistant/providers/builtin/__init__.py | 2 +- .../providers/chromecast/__init__.py | 19 ++++++------- music_assistant/providers/dlna/__init__.py | 20 +++++++------ .../providers/fanarttv/__init__.py | 4 +-- .../providers/filesystem_local/__init__.py | 11 ++++++-- .../providers/fully_kiosk/__init__.py | 13 ++++----- .../providers/hass_players/__init__.py | 14 ++++------ .../providers/opensubsonic/sonic_provider.py | 2 +- .../providers/player_group/__init__.py | 12 ++++---- music_assistant/providers/qobuz/__init__.py | 13 ++++++--- .../providers/radiobrowser/__init__.py | 11 ++++++-- .../providers/siriusxm/__init__.py | 2 +- .../providers/slimproto/__init__.py | 20 ++++++------- .../providers/snapcast/__init__.py | 16 +++++------ music_assistant/providers/sonos/provider.py | 19 +++++++------ .../providers/sonos_s1/__init__.py | 21 +++++++------- music_assistant/providers/sonos_s1/player.py | 3 +- .../providers/soundcloud/__init__.py | 10 +++++-- music_assistant/providers/spotify/__init__.py | 13 ++++++--- .../providers/theaudiodb/__init__.py | 12 +++++--- music_assistant/providers/tidal/__init__.py | 2 +- music_assistant/providers/tunein/__init__.py | 10 +++++-- music_assistant/providers/ytmusic/__init__.py | 19 ++++++++----- scripts/setup.sh | 1 + 41 files changed, 214 insertions(+), 223 deletions(-) delete mode 100644 music_assistant/helpers/global_cache.py diff --git a/music_assistant/controllers/config.py b/music_assistant/controllers/config.py index f8bfea0c6..e46a623c5 100644 --- a/music_assistant/controllers/config.py +++ b/music_assistant/controllers/config.py @@ -15,8 +15,6 @@ from cryptography.fernet import Fernet, InvalidToken from music_assistant_models import config_entries from music_assistant_models.config_entries import ( - DEFAULT_CORE_CONFIG_ENTRIES, - DEFAULT_PROVIDER_CONFIG_ENTRIES, ConfigEntry, ConfigValueType, CoreConfig, @@ -30,7 +28,7 @@ PlayerCommandFailed, UnsupportedFeaturedException, ) -from music_assistant_models.helpers.global_cache import get_global_cache_value +from music_assistant_models.helpers import get_global_cache_value from music_assistant.constants import ( CONF_CORE, @@ -38,6 +36,8 @@ CONF_PROVIDERS, CONF_SERVER_ID, CONFIGURABLE_CORE_CONTROLLERS, + DEFAULT_CORE_CONFIG_ENTRIES, + DEFAULT_PROVIDER_CONFIG_ENTRIES, ENCRYPT_SUFFIX, ) from music_assistant.helpers.api import api_command diff --git a/music_assistant/controllers/media/albums.py b/music_assistant/controllers/media/albums.py index b0cfb8568..fef594c0b 100644 --- a/music_assistant/controllers/media/albums.py +++ b/music_assistant/controllers/media/albums.py @@ -6,21 +6,13 @@ from collections.abc import Iterable from typing import TYPE_CHECKING, Any -from music_assistant_models.enums import CacheCategory, ProviderFeature +from music_assistant_models.enums import AlbumType, CacheCategory, MediaType, ProviderFeature from music_assistant_models.errors import ( InvalidDataError, MediaNotFoundError, UnsupportedFeaturedException, ) -from music_assistant_models.media_items import ( - Album, - AlbumType, - Artist, - ItemMapping, - MediaType, - Track, - UniqueList, -) +from music_assistant_models.media_items import Album, Artist, ItemMapping, Track, UniqueList from music_assistant.constants import DB_TABLE_ALBUM_ARTISTS, DB_TABLE_ALBUM_TRACKS, DB_TABLE_ALBUMS from music_assistant.controllers.media.base import MediaControllerBase diff --git a/music_assistant/controllers/media/artists.py b/music_assistant/controllers/media/artists.py index 776d907ac..52a870ae0 100644 --- a/music_assistant/controllers/media/artists.py +++ b/music_assistant/controllers/media/artists.py @@ -6,21 +6,13 @@ import contextlib from typing import TYPE_CHECKING, Any -from music_assistant_models.enums import CacheCategory, ProviderFeature +from music_assistant_models.enums import AlbumType, CacheCategory, MediaType, ProviderFeature from music_assistant_models.errors import ( MediaNotFoundError, ProviderUnavailableError, UnsupportedFeaturedException, ) -from music_assistant_models.media_items import ( - Album, - AlbumType, - Artist, - ItemMapping, - MediaType, - Track, - UniqueList, -) +from music_assistant_models.media_items import Album, Artist, ItemMapping, Track, UniqueList from music_assistant.constants import ( DB_TABLE_ALBUM_ARTISTS, diff --git a/music_assistant/controllers/media/playlists.py b/music_assistant/controllers/media/playlists.py index 5051c7433..bd141af25 100644 --- a/music_assistant/controllers/media/playlists.py +++ b/music_assistant/controllers/media/playlists.py @@ -14,11 +14,11 @@ ProviderUnavailableError, UnsupportedFeaturedException, ) -from music_assistant_models.helpers.uri import create_uri, parse_uri from music_assistant_models.media_items import Playlist, PlaylistTrack, Track from music_assistant.constants import DB_TABLE_PLAYLISTS from music_assistant.helpers.json import serialize_to_json +from music_assistant.helpers.uri import create_uri, parse_uri from music_assistant.models.music_provider import MusicProvider from .base import MediaControllerBase diff --git a/music_assistant/controllers/metadata.py b/music_assistant/controllers/metadata.py index 2c69820e6..9eab843db 100644 --- a/music_assistant/controllers/metadata.py +++ b/music_assistant/controllers/metadata.py @@ -26,7 +26,7 @@ ProviderType, ) from music_assistant_models.errors import MediaNotFoundError, ProviderUnavailableError -from music_assistant_models.helpers.global_cache import get_global_cache_value +from music_assistant_models.helpers import get_global_cache_value from music_assistant_models.media_items import ( Album, Artist, diff --git a/music_assistant/controllers/music.py b/music_assistant/controllers/music.py index b8c92578d..b8424d9d8 100644 --- a/music_assistant/controllers/music.py +++ b/music_assistant/controllers/music.py @@ -27,8 +27,7 @@ MusicAssistantError, ProviderUnavailableError, ) -from music_assistant_models.helpers.global_cache import get_global_cache_value -from music_assistant_models.helpers.uri import parse_uri +from music_assistant_models.helpers import get_global_cache_value from music_assistant_models.media_items import ( BrowseFolder, ItemMapping, @@ -55,6 +54,7 @@ from music_assistant.helpers.api import api_command from music_assistant.helpers.database import DatabaseConnection from music_assistant.helpers.datetime import utc_timestamp +from music_assistant.helpers.uri import parse_uri from music_assistant.helpers.util import TaskManager from music_assistant.models.core_controller import CoreController diff --git a/music_assistant/controllers/streams.py b/music_assistant/controllers/streams.py index b760b2829..8cc484b16 100644 --- a/music_assistant/controllers/streams.py +++ b/music_assistant/controllers/streams.py @@ -16,12 +16,7 @@ from aiofiles.os import wrap from aiohttp import web -from music_assistant_models.config_entries import ( - CONF_ENTRY_ENABLE_ICY_METADATA, - ConfigEntry, - ConfigValueOption, - ConfigValueType, -) +from music_assistant_models.config_entries import ConfigEntry, ConfigValueOption, ConfigValueType from music_assistant_models.enums import ( ConfigEntryType, ContentType, @@ -39,6 +34,7 @@ CONF_BIND_PORT, CONF_CROSSFADE, CONF_CROSSFADE_DURATION, + CONF_ENTRY_ENABLE_ICY_METADATA, CONF_HTTP_PROFILE, CONF_OUTPUT_CHANNELS, CONF_PUBLISH_IP, diff --git a/music_assistant/helpers/audio.py b/music_assistant/helpers/audio.py index 578bccf6d..dad3c5db4 100644 --- a/music_assistant/helpers/audio.py +++ b/music_assistant/helpers/audio.py @@ -14,15 +14,15 @@ import aiofiles from aiohttp import ClientTimeout -from music_assistant_models.enums import MediaType, StreamType, VolumeNormalizationMode +from music_assistant_models.enums import ContentType, MediaType, StreamType, VolumeNormalizationMode from music_assistant_models.errors import ( InvalidDataError, MediaNotFoundError, MusicAssistantError, ProviderUnavailableError, ) -from music_assistant_models.helpers.global_cache import set_global_cache_values -from music_assistant_models.media_items import AudioFormat, ContentType +from music_assistant_models.helpers import set_global_cache_values +from music_assistant_models.streamdetails import AudioFormat from music_assistant.constants import ( CONF_EQ_BASS, diff --git a/music_assistant/helpers/ffmpeg.py b/music_assistant/helpers/ffmpeg.py index 1cf911584..0405fc275 100644 --- a/music_assistant/helpers/ffmpeg.py +++ b/music_assistant/helpers/ffmpeg.py @@ -8,15 +8,18 @@ from collections.abc import AsyncGenerator from typing import TYPE_CHECKING +from music_assistant_models.enums import ContentType from music_assistant_models.errors import AudioError -from music_assistant_models.helpers.global_cache import get_global_cache_value -from music_assistant_models.media_items import AudioFormat, ContentType +from music_assistant_models.helpers import get_global_cache_value from music_assistant.constants import VERBOSE_LOG_LEVEL from .process import AsyncProcess from .util import TimedAsyncGenerator, close_async_generator +if TYPE_CHECKING: + from music_assistant_models.media_items import AudioFormat + LOGGER = logging.getLogger("ffmpeg") MINIMAL_FFMPEG_VERSION = 6 diff --git a/music_assistant/helpers/global_cache.py b/music_assistant/helpers/global_cache.py deleted file mode 100644 index 6cd741dd9..000000000 --- a/music_assistant/helpers/global_cache.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Provides a simple global memory cache.""" - -from __future__ import annotations - -import asyncio -from typing import Any - -# global cache - we use this on a few places (as limited as possible) -# where we have no other options -_global_cache_lock = asyncio.Lock() -_global_cache: dict[str, Any] = {} - - -def get_global_cache_value(key: str, default: Any = None) -> Any: - """Get a value from the global cache.""" - return _global_cache.get(key, default) - - -async def set_global_cache_values(values: dict[str, Any]) -> Any: - """Set a value in the global cache (without locking).""" - async with _global_cache_lock: - for key, value in values.items(): - _set_global_cache_value(key, value) - - -def _set_global_cache_value(key: str, value: Any) -> Any: - """Set a value in the global cache (without locking).""" - _global_cache[key] = value diff --git a/music_assistant/helpers/uri.py b/music_assistant/helpers/uri.py index 7f39b4e1f..c0f58726d 100644 --- a/music_assistant/helpers/uri.py +++ b/music_assistant/helpers/uri.py @@ -6,9 +6,13 @@ from music_assistant_models.enums import MediaType from music_assistant_models.errors import InvalidProviderID, InvalidProviderURI +from music_assistant_models.helpers import create_uri as create_uri_org base62_length22_id_pattern = re.compile(r"^[a-zA-Z0-9]{22}$") +# create alias to original create_uri function +create_uri = create_uri_org + def valid_base62_length22(item_id: str) -> bool: """Validate Spotify style ID.""" diff --git a/music_assistant/helpers/util.py b/music_assistant/helpers/util.py index 25da351af..b6e5f2b40 100644 --- a/music_assistant/helpers/util.py +++ b/music_assistant/helpers/util.py @@ -422,7 +422,7 @@ async def load_provider_module(domain: str, requirements: list[str]) -> Provider @lru_cache def _get_provider_module(domain: str) -> ProviderModuleType: - return importlib.import_module(f".{domain}", ".providers") + return importlib.import_module(f".{domain}", "music_assistant.providers") # ensure module requirements are met for requirement in requirements: diff --git a/music_assistant/mass.py b/music_assistant/mass.py index bb4119da5..f183c6835 100644 --- a/music_assistant/mass.py +++ b/music_assistant/mass.py @@ -16,7 +16,7 @@ from music_assistant_models.enums import EventType, ProviderType from music_assistant_models.errors import MusicAssistantError, SetupFailedError from music_assistant_models.event import MassEvent -from music_assistant_models.helpers.global_cache import set_global_cache_values +from music_assistant_models.helpers import set_global_cache_values from music_assistant_models.provider import ProviderManifest from zeroconf import IPVersion, NonUniqueNameException, ServiceStateChange, Zeroconf from zeroconf.asyncio import AsyncServiceBrowser, AsyncServiceInfo, AsyncZeroconf diff --git a/music_assistant/models/player_provider.py b/music_assistant/models/player_provider.py index 8d54db53d..a9491a3f4 100644 --- a/music_assistant/models/player_provider.py +++ b/music_assistant/models/player_provider.py @@ -5,22 +5,22 @@ from abc import abstractmethod from typing import TYPE_CHECKING -from music_assistant_models.config_entries import ( +from music_assistant_models.errors import UnsupportedFeaturedException +from zeroconf import ServiceStateChange +from zeroconf.asyncio import AsyncServiceInfo + +from music_assistant.constants import ( BASE_PLAYER_CONFIG_ENTRIES, CONF_ENTRY_ANNOUNCE_VOLUME, CONF_ENTRY_ANNOUNCE_VOLUME_MAX, CONF_ENTRY_ANNOUNCE_VOLUME_MIN, CONF_ENTRY_ANNOUNCE_VOLUME_STRATEGY, - ConfigEntry, - PlayerConfig, ) -from music_assistant_models.errors import UnsupportedFeaturedException -from zeroconf import ServiceStateChange -from zeroconf.asyncio import AsyncServiceInfo from .provider import Provider if TYPE_CHECKING: + from music_assistant_models.config_entries import ConfigEntry, PlayerConfig from music_assistant_models.player import Player, PlayerMedia # ruff: noqa: ARG001, ARG002 diff --git a/music_assistant/providers/airplay/provider.py b/music_assistant/providers/airplay/provider.py index 34904afef..b4a5f5bb7 100644 --- a/music_assistant/providers/airplay/provider.py +++ b/music_assistant/providers/airplay/provider.py @@ -10,18 +10,7 @@ from random import randrange from typing import TYPE_CHECKING -from music_assistant_models.config_entries import ( - CONF_ENTRY_CROSSFADE, - CONF_ENTRY_CROSSFADE_DURATION, - CONF_ENTRY_EQ_BASS, - CONF_ENTRY_EQ_MID, - CONF_ENTRY_EQ_TREBLE, - CONF_ENTRY_FLOW_MODE_ENFORCED, - CONF_ENTRY_OUTPUT_CHANNELS, - CONF_ENTRY_SYNC_ADJUST, - ConfigEntry, - create_sample_rates_config_entry, -) +from music_assistant_models.config_entries import ConfigEntry from music_assistant_models.enums import ( ConfigEntryType, ContentType, @@ -36,10 +25,16 @@ from zeroconf import ServiceStateChange from zeroconf.asyncio import AsyncServiceInfo -from music_assistant.helpers import ( - convert_airplay_volume, - get_model_from_am, - get_primary_ip_address, +from music_assistant.constants import ( + CONF_ENTRY_CROSSFADE, + CONF_ENTRY_CROSSFADE_DURATION, + CONF_ENTRY_EQ_BASS, + CONF_ENTRY_EQ_MID, + CONF_ENTRY_EQ_TREBLE, + CONF_ENTRY_FLOW_MODE_ENFORCED, + CONF_ENTRY_OUTPUT_CHANNELS, + CONF_ENTRY_SYNC_ADJUST, + create_sample_rates_config_entry, ) from music_assistant.helpers.audio import get_ffmpeg_stream from music_assistant.helpers.datetime import utc @@ -58,6 +53,7 @@ CONF_READ_AHEAD_BUFFER, FALLBACK_VOLUME, ) +from .helpers import convert_airplay_volume, get_model_from_am, get_primary_ip_address from .player import AirPlayPlayer if TYPE_CHECKING: diff --git a/music_assistant/providers/apple_music/__init__.py b/music_assistant/providers/apple_music/__init__.py index e753449f7..364e53d81 100644 --- a/music_assistant/providers/apple_music/__init__.py +++ b/music_assistant/providers/apple_music/__init__.py @@ -9,15 +9,20 @@ import aiofiles from music_assistant_models.config_entries import ConfigEntry, ConfigValueType -from music_assistant_models.enums import ConfigEntryType, ExternalID, ProviderFeature, StreamType +from music_assistant_models.enums import ( + AlbumType, + ConfigEntryType, + ContentType, + ExternalID, + ImageType, + ProviderFeature, + StreamType, +) from music_assistant_models.errors import MediaNotFoundError, ResourceTemporarilyUnavailable from music_assistant_models.media_items import ( Album, - AlbumType, Artist, AudioFormat, - ContentType, - ImageType, ItemMapping, MediaItemImage, MediaItemType, diff --git a/music_assistant/providers/bluesound/__init__.py b/music_assistant/providers/bluesound/__init__.py index bc718b4a2..47da44e1c 100644 --- a/music_assistant/providers/bluesound/__init__.py +++ b/music_assistant/providers/bluesound/__init__.py @@ -6,15 +6,6 @@ import time from typing import TYPE_CHECKING, TypedDict -from music_assistant_models.config_entries import ( - CONF_ENTRY_CROSSFADE, - CONF_ENTRY_ENABLE_ICY_METADATA, - CONF_ENTRY_ENFORCE_MP3, - CONF_ENTRY_FLOW_MODE_ENFORCED, - CONF_ENTRY_HTTP_PROFILE_FORCED_2, - ConfigEntry, - ConfigValueType, -) from music_assistant_models.enums import PlayerFeature, PlayerState, PlayerType, ProviderFeature from music_assistant_models.errors import PlayerCommandFailed from music_assistant_models.player import DeviceInfo, Player, PlayerMedia @@ -22,7 +13,14 @@ from pyblu import Status, SyncStatus from zeroconf import ServiceStateChange -from music_assistant.constants import VERBOSE_LOG_LEVEL +from music_assistant.constants import ( + CONF_ENTRY_CROSSFADE, + CONF_ENTRY_ENABLE_ICY_METADATA, + CONF_ENTRY_ENFORCE_MP3, + CONF_ENTRY_FLOW_MODE_ENFORCED, + CONF_ENTRY_HTTP_PROFILE_FORCED_2, + VERBOSE_LOG_LEVEL, +) from music_assistant.helpers.util import ( get_port_from_zeroconf, get_primary_ip_address_from_zeroconf, @@ -30,7 +28,7 @@ from music_assistant.models.player_provider import PlayerProvider if TYPE_CHECKING: - from music_assistant_models.config_entries import ProviderConfig + from music_assistant_models.config_entries import ConfigEntry, ConfigValueType, ProviderConfig from music_assistant_models.provider import ProviderManifest from zeroconf.asyncio import AsyncServiceInfo diff --git a/music_assistant/providers/builtin/__init__.py b/music_assistant/providers/builtin/__init__.py index b9b302011..504cd1075 100644 --- a/music_assistant/providers/builtin/__init__.py +++ b/music_assistant/providers/builtin/__init__.py @@ -25,7 +25,6 @@ MediaNotFoundError, ProviderUnavailableError, ) -from music_assistant_models.helpers.uri import parse_uri from music_assistant_models.media_items import ( Artist, AudioFormat, @@ -42,6 +41,7 @@ from music_assistant.constants import MASS_LOGO, RESOURCES_DIR, VARIOUS_ARTISTS_FANART from music_assistant.helpers.tags import AudioTags, parse_tags +from music_assistant.helpers.uri import parse_uri from music_assistant.models.music_provider import MusicProvider if TYPE_CHECKING: diff --git a/music_assistant/providers/chromecast/__init__.py b/music_assistant/providers/chromecast/__init__.py index 58898ed8e..549a7c269 100644 --- a/music_assistant/providers/chromecast/__init__.py +++ b/music_assistant/providers/chromecast/__init__.py @@ -12,15 +12,6 @@ from uuid import UUID import pychromecast -from music_assistant_models.config_entries import ( - BASE_PLAYER_CONFIG_ENTRIES, - CONF_ENTRY_CROSSFADE_DURATION, - CONF_ENTRY_CROSSFADE_FLOW_MODE_REQUIRED, - CONF_ENTRY_ENFORCE_MP3, - ConfigEntry, - ConfigValueType, - create_sample_rates_config_entry, -) from music_assistant_models.enums import MediaType, PlayerFeature, PlayerState, PlayerType from music_assistant_models.errors import PlayerUnavailableError from music_assistant_models.player import DeviceInfo, Player, PlayerMedia @@ -30,16 +21,22 @@ from pychromecast.socket_client import CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED from music_assistant.constants import ( + BASE_PLAYER_CONFIG_ENTRIES, CONF_ENFORCE_MP3, + CONF_ENTRY_CROSSFADE_DURATION, + CONF_ENTRY_CROSSFADE_FLOW_MODE_REQUIRED, + CONF_ENTRY_ENFORCE_MP3, CONF_PLAYERS, MASS_LOGO_ONLINE, VERBOSE_LOG_LEVEL, + create_sample_rates_config_entry, ) -from music_assistant.helpers import CastStatusListener, ChromecastInfo from music_assistant.models.player_provider import PlayerProvider +from .helpers import CastStatusListener, ChromecastInfo + if TYPE_CHECKING: - from music_assistant_models.config_entries import ProviderConfig + from music_assistant_models.config_entries import ConfigEntry, ConfigValueType, ProviderConfig from music_assistant_models.provider import ProviderManifest from pychromecast.controllers.media import MediaStatus from pychromecast.controllers.receiver import CastStatus diff --git a/music_assistant/providers/dlna/__init__.py b/music_assistant/providers/dlna/__init__.py index 97857d013..10f651ee2 100644 --- a/music_assistant/providers/dlna/__init__.py +++ b/music_assistant/providers/dlna/__init__.py @@ -22,27 +22,29 @@ from async_upnp_client.exceptions import UpnpError, UpnpResponseError from async_upnp_client.profiles.dlna import DmrDevice, TransportState from async_upnp_client.search import async_search -from music_assistant_models.config_entries import ( +from music_assistant_models.config_entries import ConfigEntry, ConfigValueType +from music_assistant_models.enums import ConfigEntryType, PlayerFeature, PlayerState, PlayerType +from music_assistant_models.errors import PlayerUnavailableError +from music_assistant_models.player import DeviceInfo, Player, PlayerMedia + +from music_assistant.constants import ( + CONF_ENFORCE_MP3, CONF_ENTRY_CROSSFADE_DURATION, CONF_ENTRY_CROSSFADE_FLOW_MODE_REQUIRED, CONF_ENTRY_ENABLE_ICY_METADATA, CONF_ENTRY_ENFORCE_MP3, CONF_ENTRY_FLOW_MODE_DEFAULT_ENABLED, CONF_ENTRY_HTTP_PROFILE, - ConfigEntry, - ConfigValueType, + CONF_PLAYERS, + VERBOSE_LOG_LEVEL, create_sample_rates_config_entry, ) -from music_assistant_models.enums import ConfigEntryType, PlayerFeature, PlayerState, PlayerType -from music_assistant_models.errors import PlayerUnavailableError -from music_assistant_models.player import DeviceInfo, Player, PlayerMedia - -from music_assistant.constants import CONF_ENFORCE_MP3, CONF_PLAYERS, VERBOSE_LOG_LEVEL -from music_assistant.helpers import DLNANotifyServer from music_assistant.helpers.didl_lite import create_didl_metadata from music_assistant.helpers.util import TaskManager from music_assistant.models.player_provider import PlayerProvider +from .helpers import DLNANotifyServer + if TYPE_CHECKING: from collections.abc import Awaitable, Callable, Coroutine, Sequence diff --git a/music_assistant/providers/fanarttv/__init__.py b/music_assistant/providers/fanarttv/__init__.py index eaaa533ba..9b8a65c14 100644 --- a/music_assistant/providers/fanarttv/__init__.py +++ b/music_assistant/providers/fanarttv/__init__.py @@ -7,8 +7,8 @@ import aiohttp.client_exceptions from music_assistant_models.config_entries import ConfigEntry -from music_assistant_models.enums import ConfigEntryType, ExternalID, ProviderFeature -from music_assistant_models.media_items import ImageType, MediaItemImage, MediaItemMetadata +from music_assistant_models.enums import ConfigEntryType, ExternalID, ImageType, ProviderFeature +from music_assistant_models.media_items import MediaItemImage, MediaItemMetadata from music_assistant.controllers.cache import use_cache from music_assistant.helpers.app_vars import app_var diff --git a/music_assistant/providers/filesystem_local/__init__.py b/music_assistant/providers/filesystem_local/__init__.py index aa7f1927c..317d8aa62 100644 --- a/music_assistant/providers/filesystem_local/__init__.py +++ b/music_assistant/providers/filesystem_local/__init__.py @@ -14,15 +14,20 @@ import xmltodict from aiofiles.os import wrap from music_assistant_models.config_entries import ConfigEntry, ConfigValueOption, ConfigValueType -from music_assistant_models.enums import ConfigEntryType, ExternalID, ProviderFeature, StreamType +from music_assistant_models.enums import ( + ConfigEntryType, + ContentType, + ExternalID, + ImageType, + ProviderFeature, + StreamType, +) from music_assistant_models.errors import MediaNotFoundError, MusicAssistantError, SetupFailedError from music_assistant_models.media_items import ( Album, Artist, AudioFormat, BrowseFolder, - ContentType, - ImageType, ItemMapping, MediaItemImage, MediaItemType, diff --git a/music_assistant/providers/fully_kiosk/__init__.py b/music_assistant/providers/fully_kiosk/__init__.py index 4cbee92f8..e773dcd0f 100644 --- a/music_assistant/providers/fully_kiosk/__init__.py +++ b/music_assistant/providers/fully_kiosk/__init__.py @@ -8,20 +8,17 @@ from typing import TYPE_CHECKING from fullykiosk import FullyKiosk -from music_assistant_models.config_entries import ( - CONF_ENTRY_CROSSFADE, - CONF_ENTRY_CROSSFADE_DURATION, - CONF_ENTRY_ENFORCE_MP3_DEFAULT_ENABLED, - CONF_ENTRY_FLOW_MODE_ENFORCED, - ConfigEntry, - ConfigValueType, -) +from music_assistant_models.config_entries import ConfigEntry, ConfigValueType from music_assistant_models.enums import ConfigEntryType, PlayerFeature, PlayerState, PlayerType from music_assistant_models.errors import PlayerUnavailableError, SetupFailedError from music_assistant_models.player import DeviceInfo, Player, PlayerMedia from music_assistant.constants import ( CONF_ENFORCE_MP3, + CONF_ENTRY_CROSSFADE, + CONF_ENTRY_CROSSFADE_DURATION, + CONF_ENTRY_ENFORCE_MP3_DEFAULT_ENABLED, + CONF_ENTRY_FLOW_MODE_ENFORCED, CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, diff --git a/music_assistant/providers/hass_players/__init__.py b/music_assistant/providers/hass_players/__init__.py index cba0a6c87..5095749c3 100644 --- a/music_assistant/providers/hass_players/__init__.py +++ b/music_assistant/providers/hass_players/__init__.py @@ -12,21 +12,19 @@ from typing import TYPE_CHECKING, Any from hass_client.exceptions import FailedCommand -from music_assistant_models.config_entries import ( +from music_assistant_models.config_entries import ConfigEntry, ConfigValueOption, ConfigValueType +from music_assistant_models.enums import ConfigEntryType, PlayerFeature, PlayerState, PlayerType +from music_assistant_models.errors import SetupFailedError +from music_assistant_models.player import DeviceInfo, Player, PlayerMedia + +from music_assistant.constants import ( CONF_ENTRY_CROSSFADE_DURATION, CONF_ENTRY_CROSSFADE_FLOW_MODE_REQUIRED, CONF_ENTRY_ENABLE_ICY_METADATA, CONF_ENTRY_ENFORCE_MP3_DEFAULT_ENABLED, CONF_ENTRY_FLOW_MODE_ENFORCED, CONF_ENTRY_HTTP_PROFILE, - ConfigEntry, - ConfigValueOption, - ConfigValueType, ) -from music_assistant_models.enums import ConfigEntryType, PlayerFeature, PlayerState, PlayerType -from music_assistant_models.errors import SetupFailedError -from music_assistant_models.player import DeviceInfo, Player, PlayerMedia - from music_assistant.helpers.datetime import from_iso_string from music_assistant.models.player_provider import PlayerProvider from music_assistant.providers.hass import DOMAIN as HASS_DOMAIN diff --git a/music_assistant/providers/opensubsonic/sonic_provider.py b/music_assistant/providers/opensubsonic/sonic_provider.py index 09fb1eafc..16c6fa899 100644 --- a/music_assistant/providers/opensubsonic/sonic_provider.py +++ b/music_assistant/providers/opensubsonic/sonic_provider.py @@ -14,6 +14,7 @@ SonicError, ) from music_assistant_models.enums import ( + AlbumType, ContentType, ImageType, MediaType, @@ -23,7 +24,6 @@ from music_assistant_models.errors import LoginFailed, MediaNotFoundError, ProviderPermissionDenied from music_assistant_models.media_items import ( Album, - AlbumType, Artist, AudioFormat, ItemMapping, diff --git a/music_assistant/providers/player_group/__init__.py b/music_assistant/providers/player_group/__init__.py index 8384da83e..32afe391a 100644 --- a/music_assistant/providers/player_group/__init__.py +++ b/music_assistant/providers/player_group/__init__.py @@ -15,16 +15,10 @@ import shortuuid from aiohttp import web from music_assistant_models.config_entries import ( - BASE_PLAYER_CONFIG_ENTRIES, - CONF_ENTRY_CROSSFADE, - CONF_ENTRY_CROSSFADE_DURATION, - CONF_ENTRY_FLOW_MODE_ENFORCED, - CONF_ENTRY_PLAYER_ICON_GROUP, ConfigEntry, ConfigValueOption, ConfigValueType, PlayerConfig, - create_sample_rates_config_entry, ) from music_assistant_models.enums import ( ConfigEntryType, @@ -45,14 +39,20 @@ from music_assistant_models.player import DeviceInfo, Player, PlayerMedia from music_assistant.constants import ( + BASE_PLAYER_CONFIG_ENTRIES, CONF_CROSSFADE, CONF_CROSSFADE_DURATION, CONF_ENABLE_ICY_METADATA, CONF_ENFORCE_MP3, + CONF_ENTRY_CROSSFADE, + CONF_ENTRY_CROSSFADE_DURATION, + CONF_ENTRY_FLOW_MODE_ENFORCED, + CONF_ENTRY_PLAYER_ICON_GROUP, CONF_FLOW_MODE, CONF_GROUP_MEMBERS, CONF_HTTP_PROFILE, CONF_SAMPLE_RATES, + create_sample_rates_config_entry, ) from music_assistant.controllers.streams import DEFAULT_STREAM_HEADERS from music_assistant.helpers.ffmpeg import get_ffmpeg_stream diff --git a/music_assistant/providers/qobuz/__init__.py b/music_assistant/providers/qobuz/__init__.py index da407d365..ee502f41b 100644 --- a/music_assistant/providers/qobuz/__init__.py +++ b/music_assistant/providers/qobuz/__init__.py @@ -10,7 +10,15 @@ from aiohttp import client_exceptions from music_assistant_models.config_entries import ConfigEntry, ConfigValueType -from music_assistant_models.enums import ConfigEntryType, ExternalID, ProviderFeature, StreamType +from music_assistant_models.enums import ( + AlbumType, + ConfigEntryType, + ContentType, + ExternalID, + ImageType, + ProviderFeature, + StreamType, +) from music_assistant_models.errors import ( InvalidDataError, LoginFailed, @@ -19,11 +27,8 @@ ) from music_assistant_models.media_items import ( Album, - AlbumType, Artist, AudioFormat, - ContentType, - ImageType, MediaItemImage, MediaItemType, MediaType, diff --git a/music_assistant/providers/radiobrowser/__init__.py b/music_assistant/providers/radiobrowser/__init__.py index 203cb4495..a38b9f44a 100644 --- a/music_assistant/providers/radiobrowser/__init__.py +++ b/music_assistant/providers/radiobrowser/__init__.py @@ -6,13 +6,18 @@ from typing import TYPE_CHECKING, cast from music_assistant_models.config_entries import ConfigEntry -from music_assistant_models.enums import ConfigEntryType, LinkType, ProviderFeature, StreamType +from music_assistant_models.enums import ( + ConfigEntryType, + ContentType, + ImageType, + LinkType, + ProviderFeature, + StreamType, +) from music_assistant_models.errors import MediaNotFoundError from music_assistant_models.media_items import ( AudioFormat, BrowseFolder, - ContentType, - ImageType, MediaItemImage, MediaItemLink, MediaItemType, diff --git a/music_assistant/providers/siriusxm/__init__.py b/music_assistant/providers/siriusxm/__init__.py index f362c9a69..e971c30ce 100644 --- a/music_assistant/providers/siriusxm/__init__.py +++ b/music_assistant/providers/siriusxm/__init__.py @@ -9,6 +9,7 @@ from music_assistant_models.enums import ( ConfigEntryType, ContentType, + ImageType, LinkType, MediaType, ProviderFeature, @@ -17,7 +18,6 @@ from music_assistant_models.errors import LoginFailed, MediaNotFoundError from music_assistant_models.media_items import ( AudioFormat, - ImageType, ItemMapping, MediaItemImage, MediaItemLink, diff --git a/music_assistant/providers/slimproto/__init__.py b/music_assistant/providers/slimproto/__init__.py index fc9aaffbd..7394d17f0 100644 --- a/music_assistant/providers/slimproto/__init__.py +++ b/music_assistant/providers/slimproto/__init__.py @@ -20,20 +20,10 @@ from aioslimproto.models import VisualisationType as SlimVisualisationType from aioslimproto.server import SlimServer from music_assistant_models.config_entries import ( - CONF_ENTRY_CROSSFADE, - CONF_ENTRY_CROSSFADE_DURATION, - CONF_ENTRY_ENFORCE_MP3, - CONF_ENTRY_EQ_BASS, - CONF_ENTRY_EQ_MID, - CONF_ENTRY_EQ_TREBLE, - CONF_ENTRY_HTTP_PROFILE_FORCED_2, - CONF_ENTRY_OUTPUT_CHANNELS, - CONF_ENTRY_SYNC_ADJUST, ConfigEntry, ConfigValueOption, ConfigValueType, PlayerConfig, - create_sample_rates_config_entry, ) from music_assistant_models.enums import ( ConfigEntryType, @@ -53,9 +43,19 @@ CONF_CROSSFADE, CONF_CROSSFADE_DURATION, CONF_ENFORCE_MP3, + CONF_ENTRY_CROSSFADE, + CONF_ENTRY_CROSSFADE_DURATION, + CONF_ENTRY_ENFORCE_MP3, + CONF_ENTRY_EQ_BASS, + CONF_ENTRY_EQ_MID, + CONF_ENTRY_EQ_TREBLE, + CONF_ENTRY_HTTP_PROFILE_FORCED_2, + CONF_ENTRY_OUTPUT_CHANNELS, + CONF_ENTRY_SYNC_ADJUST, CONF_PORT, CONF_SYNC_ADJUST, VERBOSE_LOG_LEVEL, + create_sample_rates_config_entry, ) from music_assistant.helpers.audio import get_ffmpeg_stream, get_player_filter_params from music_assistant.helpers.util import TaskManager diff --git a/music_assistant/providers/snapcast/__init__.py b/music_assistant/providers/snapcast/__init__.py index 3a4df08ca..b987c483a 100644 --- a/music_assistant/providers/snapcast/__init__.py +++ b/music_assistant/providers/snapcast/__init__.py @@ -13,15 +13,7 @@ from typing import TYPE_CHECKING, Final, cast from bidict import bidict -from music_assistant_models.config_entries import ( - CONF_ENTRY_CROSSFADE, - CONF_ENTRY_CROSSFADE_DURATION, - CONF_ENTRY_FLOW_MODE_ENFORCED, - ConfigEntry, - ConfigValueOption, - ConfigValueType, - create_sample_rates_config_entry, -) +from music_assistant_models.config_entries import ConfigEntry, ConfigValueOption, ConfigValueType from music_assistant_models.enums import ( ConfigEntryType, ContentType, @@ -39,6 +31,12 @@ from zeroconf import NonUniqueNameException from zeroconf.asyncio import AsyncServiceInfo +from music_assistant.constants import ( + CONF_ENTRY_CROSSFADE, + CONF_ENTRY_CROSSFADE_DURATION, + CONF_ENTRY_FLOW_MODE_ENFORCED, + create_sample_rates_config_entry, +) from music_assistant.helpers.audio import FFMpeg, get_ffmpeg_stream, get_player_filter_params from music_assistant.helpers.process import AsyncProcess, check_output from music_assistant.helpers.util import get_ip_pton diff --git a/music_assistant/providers/sonos/provider.py b/music_assistant/providers/sonos/provider.py index 9a611df06..636ec288a 100644 --- a/music_assistant/providers/sonos/provider.py +++ b/music_assistant/providers/sonos/provider.py @@ -16,24 +16,25 @@ from aiohttp.client_exceptions import ClientError from aiosonos.api.models import SonosCapability from aiosonos.utils import get_discovery_info -from music_assistant_models.config_entries import ( - CONF_ENTRY_CROSSFADE, - CONF_ENTRY_ENFORCE_MP3, - CONF_ENTRY_FLOW_MODE_HIDDEN_DISABLED, - ConfigEntry, - create_sample_rates_config_entry, -) +from music_assistant_models.config_entries import ConfigEntry from music_assistant_models.enums import ConfigEntryType, ContentType, ProviderFeature from music_assistant_models.errors import PlayerCommandFailed from music_assistant_models.player import DeviceInfo, PlayerMedia from zeroconf import ServiceStateChange -from music_assistant.constants import MASS_LOGO_ONLINE, VERBOSE_LOG_LEVEL -from music_assistant.helpers import get_primary_ip_address +from music_assistant.constants import ( + CONF_ENTRY_CROSSFADE, + CONF_ENTRY_ENFORCE_MP3, + CONF_ENTRY_FLOW_MODE_HIDDEN_DISABLED, + MASS_LOGO_ONLINE, + VERBOSE_LOG_LEVEL, + create_sample_rates_config_entry, +) from music_assistant.helpers.tags import parse_tags from music_assistant.models.player_provider import PlayerProvider from .const import CONF_AIRPLAY_MODE +from .helpers import get_primary_ip_address from .player import SonosPlayer if TYPE_CHECKING: diff --git a/music_assistant/providers/sonos_s1/__init__.py b/music_assistant/providers/sonos_s1/__init__.py index d983d7606..7a3fdab49 100644 --- a/music_assistant/providers/sonos_s1/__init__.py +++ b/music_assistant/providers/sonos_s1/__init__.py @@ -15,15 +15,7 @@ from dataclasses import dataclass, field from typing import TYPE_CHECKING -from music_assistant_models.config_entries import ( - CONF_ENTRY_CROSSFADE, - CONF_ENTRY_ENFORCE_MP3, - CONF_ENTRY_FLOW_MODE_HIDDEN_DISABLED, - CONF_ENTRY_HTTP_PROFILE_FORCED_1, - ConfigEntry, - ConfigValueType, - create_sample_rates_config_entry, -) +from music_assistant_models.config_entries import ConfigEntry, ConfigValueType from music_assistant_models.enums import ( ConfigEntryType, PlayerFeature, @@ -38,7 +30,16 @@ from soco import events_asyncio, zonegroupstate from soco.discovery import discover, scan_network -from music_assistant.constants import CONF_CROSSFADE, CONF_ENFORCE_MP3, VERBOSE_LOG_LEVEL +from music_assistant.constants import ( + CONF_CROSSFADE, + CONF_ENFORCE_MP3, + CONF_ENTRY_CROSSFADE, + CONF_ENTRY_ENFORCE_MP3, + CONF_ENTRY_FLOW_MODE_HIDDEN_DISABLED, + CONF_ENTRY_HTTP_PROFILE_FORCED_1, + VERBOSE_LOG_LEVEL, + create_sample_rates_config_entry, +) from music_assistant.helpers.didl_lite import create_didl_metadata from music_assistant.models.player_provider import PlayerProvider diff --git a/music_assistant/providers/sonos_s1/player.py b/music_assistant/providers/sonos_s1/player.py index 29e42c3bd..a0d0d525e 100644 --- a/music_assistant/providers/sonos_s1/player.py +++ b/music_assistant/providers/sonos_s1/player.py @@ -30,9 +30,10 @@ from soco.data_structures import DidlAudioBroadcast, DidlPlaylistContainer from music_assistant.constants import VERBOSE_LOG_LEVEL -from music_assistant.helpers import SonosUpdateError, soco_error from music_assistant.helpers.datetime import utc +from .helpers import SonosUpdateError, soco_error + if TYPE_CHECKING: from soco.events_base import Event as SonosEvent from soco.events_base import SubscriptionBase diff --git a/music_assistant/providers/soundcloud/__init__.py b/music_assistant/providers/soundcloud/__init__.py index 36013ca19..505f49845 100644 --- a/music_assistant/providers/soundcloud/__init__.py +++ b/music_assistant/providers/soundcloud/__init__.py @@ -7,13 +7,17 @@ from typing import TYPE_CHECKING from music_assistant_models.config_entries import ConfigEntry, ConfigValueType -from music_assistant_models.enums import ConfigEntryType, ProviderFeature, StreamType +from music_assistant_models.enums import ( + ConfigEntryType, + ContentType, + ImageType, + ProviderFeature, + StreamType, +) from music_assistant_models.errors import InvalidDataError, LoginFailed from music_assistant_models.media_items import ( Artist, AudioFormat, - ContentType, - ImageType, MediaItemImage, MediaType, Playlist, diff --git a/music_assistant/providers/spotify/__init__.py b/music_assistant/providers/spotify/__init__.py index 3789a194c..1d78f9ebb 100644 --- a/music_assistant/providers/spotify/__init__.py +++ b/music_assistant/providers/spotify/__init__.py @@ -11,7 +11,15 @@ from urllib.parse import urlencode from music_assistant_models.config_entries import ConfigEntry, ConfigValueType -from music_assistant_models.enums import ConfigEntryType, ExternalID, ProviderFeature, StreamType +from music_assistant_models.enums import ( + AlbumType, + ConfigEntryType, + ContentType, + ExternalID, + ImageType, + ProviderFeature, + StreamType, +) from music_assistant_models.errors import ( AudioError, LoginFailed, @@ -21,11 +29,8 @@ ) from music_assistant_models.media_items import ( Album, - AlbumType, Artist, AudioFormat, - ContentType, - ImageType, MediaItemImage, MediaItemType, MediaType, diff --git a/music_assistant/providers/theaudiodb/__init__.py b/music_assistant/providers/theaudiodb/__init__.py index ac37764ae..73777653b 100644 --- a/music_assistant/providers/theaudiodb/__init__.py +++ b/music_assistant/providers/theaudiodb/__init__.py @@ -7,13 +7,17 @@ import aiohttp.client_exceptions from music_assistant_models.config_entries import ConfigEntry -from music_assistant_models.enums import ConfigEntryType, ExternalID, ProviderFeature -from music_assistant_models.media_items import ( - Album, +from music_assistant_models.enums import ( AlbumType, - Artist, + ConfigEntryType, + ExternalID, ImageType, LinkType, + ProviderFeature, +) +from music_assistant_models.media_items import ( + Album, + Artist, MediaItemImage, MediaItemLink, MediaItemMetadata, diff --git a/music_assistant/providers/tidal/__init__.py b/music_assistant/providers/tidal/__init__.py index b42725cb4..dedfa653b 100644 --- a/music_assistant/providers/tidal/__init__.py +++ b/music_assistant/providers/tidal/__init__.py @@ -16,6 +16,7 @@ AlbumType, CacheCategory, ConfigEntryType, + ContentType, ExternalID, ImageType, MediaType, @@ -27,7 +28,6 @@ Album, Artist, AudioFormat, - ContentType, ItemMapping, MediaItemImage, MediaItemType, diff --git a/music_assistant/providers/tunein/__init__.py b/music_assistant/providers/tunein/__init__.py index 4e605c710..835441150 100644 --- a/music_assistant/providers/tunein/__init__.py +++ b/music_assistant/providers/tunein/__init__.py @@ -5,12 +5,16 @@ from typing import TYPE_CHECKING from music_assistant_models.config_entries import ConfigEntry, ConfigValueType -from music_assistant_models.enums import ConfigEntryType, ProviderFeature, StreamType +from music_assistant_models.enums import ( + ConfigEntryType, + ContentType, + ImageType, + ProviderFeature, + StreamType, +) from music_assistant_models.errors import InvalidDataError, LoginFailed, MediaNotFoundError from music_assistant_models.media_items import ( AudioFormat, - ContentType, - ImageType, MediaItemImage, MediaType, ProviderMapping, diff --git a/music_assistant/providers/ytmusic/__init__.py b/music_assistant/providers/ytmusic/__init__.py index 75a622425..b0bd73a70 100644 --- a/music_assistant/providers/ytmusic/__init__.py +++ b/music_assistant/providers/ytmusic/__init__.py @@ -11,7 +11,14 @@ import yt_dlp from music_assistant_models.config_entries import ConfigEntry, ConfigValueType -from music_assistant_models.enums import ConfigEntryType, ProviderFeature, StreamType +from music_assistant_models.enums import ( + AlbumType, + ConfigEntryType, + ContentType, + ImageType, + ProviderFeature, + StreamType, +) from music_assistant_models.errors import ( InvalidDataError, LoginFailed, @@ -20,11 +27,8 @@ ) from music_assistant_models.media_items import ( Album, - AlbumType, Artist, AudioFormat, - ContentType, - ImageType, ItemMapping, MediaItemImage, MediaItemType, @@ -38,7 +42,10 @@ from ytmusicapi.constants import SUPPORTED_LANGUAGES from ytmusicapi.exceptions import YTMusicServerError -from music_assistant.helpers import ( +from music_assistant.helpers.auth import AuthenticationHelper +from music_assistant.models.music_provider import MusicProvider + +from .helpers import ( add_remove_playlist_tracks, get_album, get_artist, @@ -56,8 +63,6 @@ refresh_oauth_token, search, ) -from music_assistant.helpers.auth import AuthenticationHelper -from music_assistant.models.music_provider import MusicProvider if TYPE_CHECKING: from music_assistant_models.config_entries import ProviderConfig diff --git a/scripts/setup.sh b/scripts/setup.sh index 1cff7a174..bf176237b 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -23,4 +23,5 @@ pip install --upgrade pip pip install --upgrade uv uv pip install -e "." uv pip install -e ".[test]" +uv pip install -r requirements_all.txt pre-commit install