From 4d8dbada7c69f03e62a72d7186d04fe2d90bb21c Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Tue, 27 Feb 2024 09:55:54 +0100 Subject: [PATCH] small fix for spotify login --- music_assistant/server/providers/spotify/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/music_assistant/server/providers/spotify/__init__.py b/music_assistant/server/providers/spotify/__init__.py index 4c3152fb..dbed1bfe 100644 --- a/music_assistant/server/providers/spotify/__init__.py +++ b/music_assistant/server/providers/spotify/__init__.py @@ -597,7 +597,7 @@ class SpotifyProvider(MusicProvider): raise LoginFailed(msg) # retrieve token with librespot retries = 0 - while retries < 20: + while retries < 5: try: retries += 1 if not tokeninfo: @@ -651,8 +651,14 @@ class SpotifyProvider(MusicProvider): "-p", self.config.get_value(CONF_PASSWORD), ] - librespot = await asyncio.create_subprocess_exec(*args) - await librespot.wait() + if self._ap_workaround: + args += ["--ap-port", "12345"] + librespot = await asyncio.create_subprocess_exec( + *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT + ) + stdout, _ = await librespot.communicate() + if stdout.decode().strip() != "authorized": + raise LoginFailed(f"Login failed for username {self.config.get_value(CONF_USERNAME)}") # get token with (authorized) librespot scopes = [ "user-read-playback-state", -- 2.34.1