Closed PostsDesert closed 7 years ago
That method takes "a list of song dictionaries or a single song dictionary". Try passing self._current['track']
instead, after changing the rating like in the example.
That worked, thanks. When I try to rate library songs using api.rate_songs(self._current, '5')
, where self._current is
{ 'absolutePosition': '01345075088707988136',
'clientId': 'a2a497f7-44e7-447f-83e6-1ccb51fed19a',
'creationTimestamp': '1482854532565532',
'deleted': False,
'id': '64452d8e-af14-30ee-a63e-fecfd421bf29',
'kind': 'sj#playlistEntry',
'lastModifiedTimestamp': '1483039223023220',
'playlistId': 'ba5bed9e-edc0-4cc7-8ee1-b61aa566ce68',
'source': '1',
'trackId': 'b3523ac8-229c-337b-a408-cc6a751f263a'}
I get another error.
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1994, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.5/dist-packages/flask_ask/core.py", line 516, in _flask_view_func
result = self._map_intent_to_view_func(self.request.intent)()
File "/home/griffith/alexaSkills/GoogleEchoMusicService.py", line 102, in thumbs_up
msg = queue.vote("thumbs up")
File "/home/griffith/alexaSkills/song.py", line 180, in vote
api.rate_songs(self._current, '5')
File "<decorator-gen-78>", line 2, in rate_songs
File "/usr/local/lib/python3.5/dist-packages/gmusicapi/utils/utils.py", line 616, in wrapper
return function(*args, **kw)
File "<decorator-gen-77>", line 2, in rate_songs
File "/usr/local/lib/python3.5/dist-packages/gmusicapi/utils/utils.py", line 593, in wrapper
return function(*args, **kw)
File "/usr/local/lib/python3.5/dist-packages/gmusicapi/clients/mobileclient.py", line 218, in rate_songs
self._make_call(mutate_call, mutations)
File "/usr/local/lib/python3.5/dist-packages/gmusicapi/clients/shared.py", line 84, in _make_call
return protocol.perform(self.session, self.validate, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/gmusicapi/protocol/shared.py", line 261, in perform
raise_from(CallFailure(err_msg, e.callname), e)
File "<string>", line 2, in raise_from
gmusicapi.exceptions.CallFailure: BatchMutateTracks: BatchMutateTracks: The server reported failure while changing the requested resource. If this wasn't caused by invalid arguments or server flakiness, please open an issue.
(requests kwargs: {'url': 'https://mclients.googleapis.com/sj/v2.5/trackbatch', 'method': 'POST', 'params': {'alt': 'json', 'dv': 0, 'hl': 'en_US', 'tier': 'aa'}, 'data': '{"mutations": [{"update": {"source": "1", "clientId": "a2a497f7-44e7-447f-83e6-1ccb51fed19a", "kind": "sj#playlistEntry", "trackId": "b3523ac8-229c-337b-a408-cc6a751f263a", "creationTimestamp": "1482854532565532", "playlistId": "ba5bed9e-edc0-4cc7-8ee1-b61aa566ce68", "absolutePosition": "01345075088707988136", "deleted": false, "rating": "5", "id": "64452d8e-af14-30ee-a63e-fecfd421bf29", "lastModifiedTimestamp": "1483039223023220"}}]}', 'headers': {'Authorization': '<omitted>', 'Content-Type': 'application/json'}})
(response was: '{"mutate_response":[{"id":"64452d8e-af14-30ee-a63e-fecfd421bf29","response_code":"INVALID_REQUEST"}]}')
What you have there is a playlist entry. While the entry points to a song, it's not in itself a song as far as Google Music is concerned. The documentation for rate_songs
gives information on what is required to be a song. In that playlist entry the trackId
field looks like a library ID, so I assume this song is in your library. That should help you out.
Thanks, that helped a lot.
When I try to rate songs using
api.rate_songs(self._current['track']['nid'], '5')
it returns this error. The docs say that for store songs it needs annid
andtrackType
key so I tried adding the track type as well.api.rate_songs(self._current['track']['storeId'], self._current['track']['trackType'], '5')
It still returned an error. Am I doing the request wrong?