142West / Shots-Alarm

0 stars 0 forks source link

Alarm fails to activate if no music is currently playing #5

Open aflynn73 opened 4 years ago

aflynn73 commented 4 years ago

Spotify fails to start playback of selected alarm song, as there is no active playback device:

ERROR:spotipy.client:HTTP Error for PUT to https://api.spotify.com/v1/me/player/play returned 404 due to Player command failed: No active device found Exception in thread Thread-4: Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/spotipy/client.py", line 170, in _internal_call response.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/me/player/play

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "/home/mop/Python/ShotsAlarm/src/shotsAlarm2.0.py", line 75, in spotipy_activate_thread_call mySpotipy.alarm_activate() File "/home/mop/Python/ShotsAlarm/src/util/ShotsAlarmSpotipy.py", line 258, in alarm_activate self.play_no_context(self.alarmTrackURI) File "/home/mop/Python/ShotsAlarm/src/util/ShotsAlarmSpotipy.py", line 171, in play_no_context position_ms = None) File "/usr/local/lib/python3.7/dist-packages/spotipy/client.py", line 1324, in start_playback self._append_device_id("me/player/play", device_id), payload=data File "/usr/local/lib/python3.7/dist-packages/spotipy/client.py", line 220, in _put return self._internal_call("PUT", url, payload, kwargs) File "/usr/local/lib/python3.7/dist-packages/spotipy/client.py", line 185, in _internal_call headers=response.headers, spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play: Player command failed: No active device found

aflynn73 commented 4 years ago

This may be addressable by setting a default playback device ID in Private