mopidy / mopidy-beets

Mopidy extension for playing music from a Beets collection
https://mopidy.com/ext/beets/
MIT License
49 stars 14 forks source link

Search doesn't work #10

Closed peterjeschke closed 8 years ago

peterjeschke commented 9 years ago

I installed mopidy and tried to connect to a running beets website. Every time I try to search using ncmpcpp or start sonata (I guess sonata tries to search at startup), I'm getting an exception:

ERROR    Request http://localhost:8337/item/, failed with status code 400
ERROR    Unhandled exception in MpdSession (urn:uuid:64d95e14-fd02-440d-97be-2a3fc1c8f4d9):
Traceback (most recent call last):
  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 303, in _handle_receive
    return self.on_receive(message)
  File "/usr/lib64/python2.7/site-packages/mopidy/utils/network.py", line 366, in on_receive
    self.on_line_received(line)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/session.py", line 33, in on_line_received
    response = self.dispatcher.handle_request(line)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 46, in handle_request
    return self._call_next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 75, in _catch_mpd_ack_errors_filter
    return self._call_next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 85, in _authenticate_filter
    return self._call_next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 104, in _command_list_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 133, in _idle_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 146, in _add_ok_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 158, in _call_handler_filter
    response = self._format_response(self._call_handler(request))
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/dispatcher.py", line 167, in _call_handler
    return protocol.commands.call(tokens, context=self.context)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/protocol/__init__.py", line 178, in call
    return self.handlers[tokens[0]](context, *tokens[1:])
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/protocol/__init__.py", line 140, in validate
    return func(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/protocol/music_db.py", line 271, in list_
    return _list_artist(context, query)
  File "/usr/lib64/python2.7/site-packages/mopidy/mpd/protocol/music_db.py", line 288, in _list_artist
    results = context.core.library.find_exact(**query).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/lib64/python2.7/site-packages/mopidy/core/library.py", line 118, in find_exact
    return [result for result in pykka.get_all(futures) if result]
  File "/usr/lib/python2.7/site-packages/pykka/future.py", line 330, in get_all
    return [future.get(timeout=timeout) for future in futures]
  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/lib64/python2.7/site-packages/mopidy_beets/library.py", line 18, in find_exact
    return self.search(query=query, uris=uris)
  File "/usr/lib64/python2.7/site-packages/mopidy_beets/library.py", line 29, in search
    tracks=self.remote.get_tracks())
  File "/usr/lib64/python2.7/site-packages/mopidy_beets/client.py", line 39, in _memoized
    value = self.func(*args)
  File "/usr/lib64/python2.7/site-packages/mopidy_beets/client.py", line 64, in get_tracks
    track_ids = self._get('/item/').get('item_ids')
AttributeError: 'bool' object has no attribute 'get'

This is the log for sonata, searching with ncmpcpp just changes tu URL.

Looking at the beets log, nothing happened there:

$ beet web
 * Running on http://localhost:8337/

When I enter the requested URL (http://localhost:8337/item/) in my browser, I get a valid response and the beet-log shows the request.

sumpfralle commented 8 years ago

Hi, thank you for your bug report. The code changed and improved a lot meanwhile - thus your issue should be fixed now.