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

`suggestedQuery' not defined by 'properties' #305

Closed jdarnold closed 9 years ago

jdarnold commented 9 years ago

A new one when searching All Access:

2015-01-16 11:38:46,257 - gmusicapi.Mobileclient1 (shared:282) [ERROR]: the response format for Search was not recognized.

additional property 'suggestedQuery' not defined by 'properties' are not allowed in field '_data'

First, try the develop branch. If you can recreate this error with the most recent code please [create an issue](http://goo.gl/qbAW8) that includes the above ValidationException and the following request/response:
{'url': 'https://mclients.googleapis.com/sj/v1.10/query', 'headers': {'Authorization': '<omitted>'}, 'params': {'q': u'MAJID BEKKAS CHOROQ', 'max-results': 100}, 'method': 'GET'}

'{\n "kind": "sj#searchresponse",\n "entries": [\n  {\n   "type": "1",\n   "track": {\n    "kind": "sj#track",\n    "title": "Choroq (feat. Khalid Kouhen, Manuel Hermia)",\n    "artist": "Majid Bekkas",\n    "composer": "Majid Bekkas",\n    "album": "Al Qantara",\n    "albumArtist": "Majid Bekkas",\n    "year": 2014,\n    "trackNumber": 5,\n    "genre": "Jazz",\n    "durationMillis": "601000",\n    "albumArtRef": [\n     {\n      "url": "http://lh4.ggpht.com/tkiYPt_3fniD-IAk-IZnNlK5DxOc9YtJMOFPZD_JfuPs8lV7BrC_X6TpuRC9o3kuweJ1yUjmIA"\n     }\n    ],\n    "playCount": 1,\n    "discNumber": 1,\n    "estimatedSize": "24053578",\n    "trackType": "7",\n    "storeId": "Tsb6ipncwhfhxjzevd36olgueiu",\n    "albumId": "B27eydlevz6y3dx4vboo5ivxlje",\n    "artistId": [\n     "Awfe6qf4hgpukflhv64uruf2p3u",\n     "Ajq6ihfggydrtyruw4yrjekg7d4",\n     "Algbx6ckve5l4ejo7xsdef26o24"\n    ],\n    "nid": "Tsb6ipncwhfhxjzevd36olgueiu",\n    "trackAvailableForSubscription": true,\n    "trackAvailableForPurchase": true,\n    "albumAvailableFor...'

A traceback follows:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/gmusicapi/protocol/shared.py", line 249, in perform
    cls.validate(response, parsed_response)
  File "/usr/lib/python2.7/site-packages/gmusicapi/protocol/mobileclient.py", line 258, in validate
    return validictory.validate(msg, cls._res_schema)
  File "/usr/lib/python2.7/site-packages/validictory/__init__.py", line 33, in validate
    return v.validate(data, schema)
  File "/usr/lib/python2.7/site-packages/validictory/validator.py", line 569, in validate
    self._validate(data, schema)
  File "/usr/lib/python2.7/site-packages/validictory/validator.py", line 572, in _validate
    self.__validate("_data", {"_data": data}, schema)
  File "/usr/lib/python2.7/site-packages/validictory/validator.py", line 603, in __validate
    newschema.get(schemaprop))
  File "/usr/lib/python2.7/site-packages/validictory/validator.py", line 364, in validate_additionalProperties
    None, fieldname, prop=eachProperty)
  File "/usr/lib/python2.7/site-packages/validictory/validator.py", line 148, in _error
    raise FieldValidationError(message, fieldname, value)
ValidationException: additional property 'suggestedQuery' not defined by 'properties' are not allowed in field '_data'
JVMed commented 9 years ago

I get the same error with certain search terms. Seems to occur when there are lots of overall results even while limiting api.search_all_access(s, 10). For example, error occurs with "I Got U Duke Dumont" but not with "Busy Earnin' Jungle". However the results are still usable as demonstrated below, can still add to playlists:

#!/usr/bin/python

s = "I Got U Duke Dumont" # error occurs with this search term
# s = "Busy Earnin' Jungle" # but not with this one

from gmusicapi import Mobileclient

#Google account details
email = 'YOUR EMAIL HERE'
password = 'YOUR PASSWORD HERE'

global api 
api = Mobileclient()
logged_in = api.login(email, password)
# logged_in is True if login was successful
if not logged_in:
    print('Failed to login to Google Play Music, check username and password\n')
    sys.exit()
print('\nLogged into Google Play Music, username: "%s"' % email)

results = api.search_all_access(s, 10)['song_hits']

playlist_id = api.create_playlist("new")

for r in results:
    print('\n\n')
    print(r)
    api.add_songs_to_playlist(playlist_id, r['track']['nid'])
soulfx commented 9 years ago

I've been seeing this error too.

This seems to be showing up for searches that may be using a sub-optimal query string like a misspelled artist or title or for a search that the algorithms determined that it took a while to come up with a result. Google may be returning a suggestedQuery string so that next time if the same song is searched for again the suggestedQuery will return a quicker result, something like the 'did you mean:' thing that pops up on google's regular search.

simon-weber commented 9 years ago

Thanks for digging into this, folks!

Closed by #307.