From e55040e8eea4d2a429810bf9d960d7bfd38d6930 Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Sun, 14 Jan 2024 00:19:31 +0100 Subject: [PATCH] SpotifyRecorder: handle no current playback --- SpotifyRecorder.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SpotifyRecorder.py b/SpotifyRecorder.py index 7b50122..18a2876 100644 --- a/SpotifyRecorder.py +++ b/SpotifyRecorder.py @@ -197,7 +197,11 @@ class SpotifyRecorder: self._spotify.start_playback(device_id=deviceId, uris=[trackUri]) def __stop_playback_if_playing(self, deviceId: str) -> None: - if self._spotify.current_playback()['is_playing']: + currentPlayback = self._spotify.current_playback() + if currentPlayback is None: + return + + if currentPlayback['is_playing']: self._spotify.pause_playback(device_id=deviceId) def __wait_for_track_playing(self, expectedTrackId: str) -> float: -- GitLab