From a7c6f5ec86ba3be84609517715ba355b38e61bd2 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Thu, 23 Jun 2022 11:17:17 +0200 Subject: [PATCH] Add some additional logging for common mistakes (#382) * raise error when spotify account used * print warning when emailaddress used for tunein --- music_assistant/music_providers/spotify.py | 10 +++++++++- music_assistant/music_providers/tunein.py | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/music_assistant/music_providers/spotify.py b/music_assistant/music_providers/spotify.py index f95e31b5..f9da7013 100644 --- a/music_assistant/music_providers/spotify.py +++ b/music_assistant/music_providers/spotify.py @@ -70,7 +70,15 @@ class SpotifyProvider(MusicProvider): self._cache_dir = os.path.join(CACHE_DIR, self.id) token = await self.get_token() if not token: - raise LoginFailed(f"Login failed for user {self.config.username}") + try: + # a spotify free/basic account can be recoognized when + # the username consists of numbers only - check that here + int(self.config.username) + # an integer can be parsed of the username, this is a free account + raise LoginFailed("Only Spotify Premium accounts are supported") + except ValueError: + # pylint: disable=raise-missing-from + raise LoginFailed(f"Login failed for user {self.config.username}") return True async def search( diff --git a/music_assistant/music_providers/tunein.py b/music_assistant/music_providers/tunein.py index 239896d4..e39c2cc7 100644 --- a/music_assistant/music_providers/tunein.py +++ b/music_assistant/music_providers/tunein.py @@ -38,6 +38,11 @@ class TuneInProvider(MusicProvider): return False if not self.config.username: raise LoginFailed("Username is invalid") + if "@" in self.config.username: + self.logger.warning( + "Emailadress detected instead of username, " + "it is advised to use the tunein username instead of email." + ) return True async def search( -- 2.34.1