forslund / spotify-skill

Mycroft Skill to control spotify using the Spotify Connect API
Apache License 2.0
72 stars 38 forks source link

Errors on resuming after 'stop' command #78

Closed krisgesling closed 5 years ago

krisgesling commented 5 years ago

To reproduce:

  1. Play song
  2. "Stop"
  3. "Play"
05:40:12.160 - SpotifySkill - INFO - Resume Spotify
05:40:12.170 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.spotify.com:443
05:40:12.240 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
05:40:12.713 - urllib3.connectionpool - DEBUG - https://api.spotify.com:443 "GET /v1/me/player/currently-playing HTTP/1.1" 200 None
05:40:12.726 - SpotifySkill - INFO - spotify_play: {'name': 'M1-Blue', 'is_restricted': False, 'type': 'Speaker', 'id': '87ae72b4a96cceadc3ae104587a18a690cd8e440', 'is_active': True, 'volume_percent': 80, 'is_private_session': False}
05:40:12.741 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.spotify.com:443
05:40:13.293 - urllib3.connectionpool - DEBUG - https://api.spotify.com:443 "PUT /v1/me/player/play?device_id=%7B'name':%20'M1-Blue',%20'is_restricted':%20False,%20'type':%20'Speaker',%20'id':%20'87ae72b4a96cceadc3ae104587a18a690cd8e440',%20'is_active':%20True,%20'volume_percent':%2080,%20'is_private_session':%20False%7D HTTP/1.1" 404 None
05:40:13.312 - mycroft-spotify_forslund.spotify:play:133 - ERROR - http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=%7B'name':%20'M1-Blue',%20'is_restricted':%20False,%20'type':%20'Speaker',%20'id':%20'87ae72b4a96cceadc3ae104587a18a690cd8e440',%20'is_active':%20True,%20'volume_percent':%2080,%20'is_private_session':%20False%7D:
 Device not found
05:40:13.329 - SKILLS - DEBUG - {"data": {"expect_response": false, "utterance": "An error occurred while processing a request in Spotify Skill"}, "type": "speak", "context": {}}
05:40:13.332 - mycroft.skills.core:wrapper:996 - ERROR - An error occurred while processing a request in Spotify Skill
Traceback (most recent call last):
  File "/opt/venvs/mycroft-core/lib/python3.4/site-packages/spotipy/client.py", line 119, in _internal_call
    r.raise_for_status()
  File "/opt/venvs/mycroft-core/lib/python3.4/site-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?device_id=%7B'name':%20'M1-Blue',%20'is_restricted':%20False,%20'type':%20'Speaker',%20'id':%20'87ae72b4a96cceadc3ae104587a18a690cd8e440',%20'is_active':%20True,%20'volume_percent':%2080,%20'is_private_session':%20False%7D

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/mycroft/skills/mycroft-spotify.forslund/__init__.py", line 612, in spotify_play
    self.spotify.play(dev_id, uris, context_uri)
  File "/opt/mycroft/skills/mycroft-spotify.forslund/spotify.py", line 131, in play
    self._put(path, payload=data)
  File "/opt/venvs/mycroft-core/lib/python3.4/site-packages/spotipy/client.py", line 188, in _put
    return self._internal_call('PUT', url, payload, kwargs)
  File "/opt/venvs/mycroft-core/lib/python3.4/site-packages/spotipy/client.py", line 124, in _internal_call
    headers=r.headers)
spotipy.client.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=%7B'name':%20'M1-Blue',%20'is_restricted':%20False,%20'type':%20'Speaker',%20'id':%20'87ae72b4a96cceadc3ae104587a18a690cd8e440',%20'is_active':%20True,%20'volume_percent':%2080,%20'is_private_session':%20False%7D:
 Device not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venvs/mycroft-core/lib/python3.4/site-packages/mycroft/skills/core.py", line 987, in wrapper
    handler(message)
  File "/opt/mycroft/skills/mycroft-spotify.forslund/__init__.py", line 800, in resume
    self.spotify_play(self.dev_id)
  File "/opt/mycroft/skills/mycroft-spotify.forslund/__init__.py", line 617, in spotify_play
    raise SpotifyNotAuthorizedError
mycroft-spotify_forslund.SpotifyNotAuthorizedError
forslund commented 5 years ago

Thanks for the very nice report.

Seems like unpause after stop isn't quite working. I'll push a fix during the day.