simon-weber / gmusicapi

An unofficial client library for Google Music.
https://unofficial-google-music-api.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.48k stars 257 forks source link

problem with Mobileclient.create_station() method invoked on songs id #171

Closed mario-tux closed 11 years ago

mario-tux commented 11 years ago

Hi Simon, I've just found that my gmusicproxy gets an exception using create_station() using a song_id. It works with an artist id. I think it worked in recent past: maybe something changed on the GPM side...

I've stripped all the non-essential params and, after a correct login, if I call the method like api.create_station(name='test station', track_id='T44yapwk4h3zz6splxkxelq64be'), then I get the following exception: could you verify by yourown with the same params?

DEBUG:gmusicapi.Mobileclient1:BatchMutateStations(args=[[{'create': {'tracks': [], 'seed': {'trackLockerId': 'T44yapwk4h3zz6splxkxelq64be'}, 'imageType': 1, 'deleted': False, 'lastModifiedTimestamp': '-1', 'recentTimestamp': '1379680896000000', 'clientId': 'fd00e18c-21f1-11e3-91bd-002710dd7708', 'name': 'test station'}, 'includeFeed': False, 'params': {'contentFilter': 1}, 'numEntries': 0}]], kwargs={})
DEBUG:gmusicapi.Mobileclient1:{u'mutate_response': [{u'response_code': u'INVALID_REQUEST', u'id': u''}]}
/home/mario/.virtualenvs/gmusicproxy/local/lib/python2.7/site-packages/gmusicapi/protocol/shared.py:258: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  e_message=e.message,
----------------------------------------
Exception happened during processing of request from ('192.168.200.25', 42139)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "./GMusicProxy", line 378, in handle_one_request
    BaseHTTPServer.BaseHTTPRequestHandler.handle_one_request(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "./GMusicProxy", line 118, in do_GET
    self._get_new_station(id=params['id'][0], type=params['type'][0].lower().strip(), numTracks=params['num_tracks'][0] if 'num_tracks' in params else defaultNumberTracksStation, transient=params['transient'][0].lower().strip() if 'transient' in params else 'yes', name=params['name'][0] if 'name' in params else transientStationName)
  File "./GMusicProxy", line 230, in _get_new_station
    stationId = api.create_station(name='test station', track_id='T44yapwk4h3zz6splxkxelq64be')  ## DEBUG
  File "/home/mario/.virtualenvs/gmusicproxy/local/lib/python2.7/site-packages/gmusicapi/clients/mobileclient.py", line 346, in create_station
    res = self._make_call(mutate_call, [add_mutation])
  File "/home/mario/.virtualenvs/gmusicproxy/local/lib/python2.7/site-packages/gmusicapi/clients/shared.py", line 67, in _make_call
    return protocol.perform(self.session, self.validate, *args, **kwargs)
  File "/home/mario/.virtualenvs/gmusicproxy/local/lib/python2.7/site-packages/gmusicapi/protocol/shared.py", line 246, in perform
    cls.check_success(response, parsed_response)
  File "/home/mario/.virtualenvs/gmusicproxy/local/lib/python2.7/site-packages/gmusicapi/protocol/mobileclient.py", line 336, in check_success
    cls.__name__)
CallFailure: BatchMutateStations: 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://www.googleapis.com/sj/v1/radio/editstation', 'headers': {'Content-Type': 'application/json', 'Authorization': '<omitted>'}, 'data': '{"mutations": [{"create": {"tracks": [], "seed": {"trackLockerId": "T44yapwk4h3zz6splxkxelq64be"}, "imageType": 1, "deleted": false, "lastModifiedTimestamp": "-1", "recentTimestamp": "1379680896000000", "clientId": "fd00e18c-21f1-11e3-91bd-002710dd7708", "name": "test station"}, "includeFeed": false, "params": {"contentFilter": 1}, "numEntries": 0}]}', 'method': 'POST', 'params': {'alt': 'json'}})
(response was: '{\n "mutate_response": [\n  {\n   "id": "",\n   "response_code": "INVALID_REQUEST"\n  }\n ]\n}\n')
----------------------------------------
simon-weber commented 11 years ago

Interesting; thanks for reporting this. Apparently this reflects a hole in my tests at the moment.

To actually fix this, I'll need to look into the most recent android app, which will have to wait until at least next week. Hopefully I'll be able to fix #155, #163 and #170 at the same time I get to this.

simon-weber commented 11 years ago

I also updated the tests to verify all the supported types radio seeding, so hopefully we'll catch this quickly if it happens again.

mario-tux commented 11 years ago

Hi Simon, I can confirm that it works now for me! Thanks.