fondberg / spotcast

Home assistant custom component to start Spotify playback on an idle chromecast device as well as control spotify connect devices
Apache License 2.0
702 stars 100 forks source link

After update to v3.6.19 I have Get Playlist 404 #261

Closed snp88 closed 3 years ago

snp88 commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

Describe the bug After last update v3.6.19 new error apper Can't get playlist

image

Debug log 2021-11-04 10:50:44 ERROR (SyncWorker_7) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/views/playlists returned 404 due to Not found. 2021-11-04 10:50:44 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.playlists_sensor fails Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/spotipy/client.py", line 245, in _internal_call response.raise_for_status() File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 953, 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/views/playlists?content_limit=10&locale=en&platform=web&types=album%2Cplaylist%2Cartist%2Cshow%2Cstation&limit=10&offset=0 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 468, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 658, in async_device_update raise exc File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/spotcast/sensor.py", line 98, in update resp = self.hass.data[DOMAIN]["controller"].get_playlists( File "/config/custom_components/spotcast/spotcast_controller.py", line 293, in get_playlists resp = client._get( File "/usr/local/lib/python3.9/site-packages/spotipy/client.py", line 291, in _get return self._internal_call("GET", url, payload, kwargs) File "/usr/local/lib/python3.9/site-packages/spotipy/client.py", line 261, in _internal_call raise SpotifyException( spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/views/playlists?content_limit=10&locale=en&platform=web&types=album%2Cplaylist%2Cartist%2Cshow%2Cstation&limit=10&offset=0: Not found., reason: None

Environment (please complete the following information):

Configuration Add your configuration

Additional context Add any other context about the problem here.

snp88 commented 3 years ago

maybe this can help

https://github.com/spotify/web-api/issues/434

fcusson commented 3 years ago

@snp88 can you try to upgrade to v3.6.20, it should resolve your problem. Can you confirm

snp88 commented 3 years ago

@Darkfull-Dante

Looks good on v3.6.20

image

gmcmicken commented 3 years ago

I believe you were seeing this error because an invalid "playlist_type" value was passed to the method. By design the new functionality must accept any string and pass this through to spotify API. To get your saved playlists you should pass user or default and not playlists. The previous functionality always returned user playlists if you passed an arbitrary string.

Valid values are: user, or default for user chosen saved playlists, featured for spotify "featured" playlists, and then any custom view that exists for your user such as discover-weekly recently-played, etc.

@snp88 Were you manually calling the get_playlists method with "playlists" as the argument? or perhaps this was some spotcast setup/initialize call?

jazzyisj commented 3 years ago

I also had this issue with the playlists sensor with v3.6.19. Sensor is back after update. Log errors appeared on startup before any spotcast service calls.

gmcmicken commented 3 years ago

Thanks @jazzyisj okay so it's for users who have:

sensor:
  - platform: spotcast

in their config (I did not), and I can see in sensor.py it is calling get_playlists with "playlists" which is a little strange because it doesn't follow what is expected from spotcast controller!

Anyway, it's a simple fix we can get in.

fcusson commented 3 years ago

@gmcmicken @snp88 to be completely honest its fully my fault, I completely forgot to activate the sensor when doing QA. I'll work on a proper QA procedure that we can add in our documentation, so we don't make silly mistaken like this one. Sorry for any inconvenient that the bad release might have caused

fcusson commented 3 years ago

263 resolves merge problems, I'll test the new code

jazzyisj commented 3 years ago

@Darkfull-Dante just confirming I have updated to 3.6.21 and all seems ok.

Thank you for the rapid bugfix!

snp88 commented 3 years ago

@Darkfull-Dante Good job Spotcast work like a charm 👍