Fix: Reauthenticate with SiriusXM when playing a station (#1789)
authorBrian O'Connor <btoconnor@users.noreply.github.com>
Fri, 29 Nov 2024 17:10:02 +0000 (12:10 -0500)
committerGitHub <noreply@github.com>
Fri, 29 Nov 2024 17:10:02 +0000 (18:10 +0100)
music_assistant/providers/siriusxm/__init__.py

index f32b5fbda14935953a5b4e5e9170b0c234734bca..36724642569a2dcc908dba880238ca3474c3236f 100644 (file)
@@ -215,6 +215,15 @@ class SiriusXMProvider(MusicProvider):
         self, item_id: str, media_type: MediaType = MediaType.RADIO
     ) -> StreamDetails:
         """Get streamdetails for a track/radio."""
+        # There's a chance that the SiriusXM auth session has expired
+        # by the time the user clicks to play a station.  The sxm-client
+        # will attempt to reauthenticate automatically, but this causes
+        # a delay in streaming, and ffmpeg raises a TimeoutError.
+        # To prevent this, we're going to explicitly authenticate with
+        # SiriusXM proactively when a station has been chosen to avoid
+        # this.
+        await self._client.authenticate()
+
         hls_path = f"http://{self._base_url}/{item_id}.m3u8"
 
         # Keep a reference to the current `StreamDetails` object so that we can