dirkgroenen / mopidy-mopify

A web client that uses external web services to provide additional features and a more “complete” music experience.
Apache License 2.0
447 stars 44 forks source link

Search with mopidyservice error #181

Closed loicfavory closed 8 years ago

loicfavory commented 8 years ago

I've got an error when using search: search on Spotify work fine, but the loader never stop so it never display search results. In /src/app/search/search.controller.js line 141, data is an empty array, so data[0].tracks != undefined is causing an error. I correct it testing if data is not empty:

if (data.length > 0 && data[0].tracks !== undefined)   
{ 
    $scope.results.tracks = data[0].tracks.splice(0, 100);    
}

Maybe it's because I don't have any local files ?

dirkgroenen commented 8 years ago

It looks like the Spotify backend is creating an error:

INFO     Searching Spotify for: "old man"
ERROR    SpotifyBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/mopidy/core/library.py", line 19, in _backend_error_handling
    yield
  File "/usr/lib/python2.7/site-packages/mopidy/core/library.py", line 344, in search
    result = future.get()
  File "/usr/lib/python2.7/site-packages/pykka/future.py", line 299, in get
    exec('raise exc_info[0], exc_info[1], exc_info[2]')
  File "/usr/lib/python2.7/site-packages/pykka/actor.py", line 200, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/lib/python2.7/site-packages/pykka/actor.py", line 294, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/usr/lib/python2.7/site-packages/mopidy_spotify/library.py", line 42, in search
    query, uris, exact)
  File "/usr/lib/python2.7/site-packages/mopidy_spotify/search.py", line 44, in search
    sp_search.load()
  File "/usr/lib/python2.7/site-packages/spotify/search.py", line 110, in load
    return utils.load(self._session, self, timeout=timeout)
  File "/usr/lib/python2.7/site-packages/spotify/utils.py", line 242, in load
    _check_error(obj)
  File "/usr/lib/python2.7/site-packages/spotify/utils.py", line 206, in _check_error
    error_type, ignores=[spotify.ErrorType.IS_LOADING])
  File "/usr/lib/python2.7/site-packages/spotify/error.py", line 31, in maybe_raise
    raise LibError(error_type)
LibError: General transient error

I've added your fix which should test for empty data. Mopidy-spotify will release a new version soon which fixes this error (https://github.com/mopidy/mopidy-spotify/issues/89).

kingosticks commented 8 years ago

@dirkgroenen Do you use the search results from Mopidy? If not, is it worth setting the search uris argument to everything except spotify: so you don't have to wait for the spotify results and avoid exposing yourself to issues like this?

dirkgroenen commented 8 years ago

It's a blend: tracks are coming from Mopidy and other info is coming from Spotify. I could indeed partially show the Spotify results and add the Mopidy results later, but I don't think that's necessary tight now since there's a fix on its way.

dirkgroenen commented 8 years ago

Closing for now, fix is in new version 1.5.15.

kingosticks commented 8 years ago

Ah OK I understand now, yeh makes sense.