codyfish / ulauncher-mpd

GNU General Public License v3.0
2 stars 2 forks source link

MpdClient error with remote servers #3

Open codyfish opened 4 years ago

codyfish commented 4 years ago

Hi, no it doesn't. I type "mpd artist-add" and press enter I got an entry with "loading..." I type "mpd artist-add muse" I got an entry with "loading..." and an exception in the console.

Maybe it should be handled in a different issue ?

mpd.base.CommandError: [2@0] {list} should be "Album" for 3 arguments [<Action.ADD_ARTIST: 13>] Traceback (most recent call last): File "/usr/lib/python3/dist-packages/ulauncher/api/client/Client.py", line 54, in on_message self.extension.trigger_event(event) File "/usr/lib/python3/dist-packages/ulauncher/api/client/Extension.py", line 52, in trigger_event action = listener.on_event(event, self) File "/home/laurent/.local/share/ulauncher/extensions/com.github.codyfish.ulauncher-mpd/main.py", line 35, in on_event return self.__mpd_controller.query(event.get_argument()) File "/home/laurent/.local/share/ulauncher/extensions/com.github.codyfish.ulauncher-mpd/MpdController.py", line 89, in query return Results.list_music(self.client, self.album_art_cache, command_suggestions[0], args) File "/home/laurent/.local/share/ulauncher/extensions/com.github.codyfish.ulauncher-mpd/Results.py", line 144, in list_music return list_artists(client, album_art_cache, Action.ADD_ARTIST, args) File "/home/laurent/.local/share/ulauncher/extensions/com.github.codyfish.ulauncher-mpd/Results.py", line 199, in list_artists artist_results = client.list('artist', "(artist =~ '(?i){}.*$')".format(args)) File "/usr/local/lib/python3.6/dist-packages/mpd/base.py", line 381, in mpd_command return wrapper(self, name, args, callback) File "/usr/local/lib/python3.6/dist-packages/mpd/base.py", line 473, in _execute return retval() File "/usr/local/lib/python3.6/dist-packages/mpd/base.py", line 371, in command_callback res = self._wrap_iterator(res) File "/usr/local/lib/python3.6/dist-packages/mpd/base.py", line 560, in _wrap_iterator return list(iterator) File "/usr/local/lib/python3.6/dist-packages/mpd/base.py", line 279, in _parse_list for key, value in self._parse_pairs(lines): File "/usr/local/lib/python3.6/dist-packages/mpd/base.py", line 219, in _parse_pairs for line in lines: File "/usr/local/lib/python3.6/dist-packages/mpd/base.py", line 538, in _read_lines line = self._read_line() File "/usr/local/lib/python3.6/dist-packages/mpd/base.py", line 527, in _read_line raise CommandError(error) mpd.base.CommandError: [2@0] {list} should be "Album" for 3 arguments

Originally posted by @ragusa87 in https://github.com/codyfish/ulauncher-mpd/issues/2#issuecomment-611037814

codyfish commented 4 years ago

Yeah this seems to be an entirely new issue. So far most issues have been not finding files needed for album arts, whereas this seems to be a problem with mpd.MpdClient.

Could you try album add and song add as well?

How are you normally searching for songs in your database.? If you use mpc, does mpc list artist "(artist =~ '(?i)muse.*$')" work?

Edit: https://github.com/beetbox/beets/pull/3215 seems to be similar.

Could your try mpc list 'albumartist' "(artist =~ '(?i)eminem.*$')" as well?

ragusa87 commented 4 years ago

Hi, yes, I can have a look at it. but not today. I keep you posted.

codyfish commented 4 years ago

No problem, thanks for your contribution!

ragusa87 commented 4 years ago

This may help:

mpc version

mpd version: 0.21.4

mpd -V

Music Player Daemon 0.21.5 (0.21.5)

lsb_release -a

No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster

===

mpc list artist "(artist =~ '(?i)muse.*$')"

arguments must be pairs of search types and queries The the output is the list of all the artists.

mpc list 'albumartist' "(artist =~ '(?i)eminem.*$')

arguments must be pairs of search types and queries The the output is the list of all the artists.

mpc search artist eminem

Works by displaying all song from Eminem. (not that it is case insensitive)

mpc search '(( artist =~ 'Eminem' ))'

arguments must be pairs of search types and queries mpd error: too few arguments for "search" No result

mpc search '((artist == "Muse"))'

arguments must be pairs of search types and queries mpd error: too few arguments for "search"

bretello commented 4 years ago

I have the same issue, I'll try and see if I can fix it

codyfish commented 4 years ago

Sorry for my late answer.

Do you use mpd with perl support. The queries right now are using perl regexes to filter songs case insensitive.

https://www.musicpd.org/doc/html/protocol.html#filters

Reimplementing this could take some time. If you want to, I would be happy if you tried/helped of course

I have mpd version 0.21.22 It shows a lot more plugins and information than yours does, however none of it seems to refer to perl regexes.

bretello commented 4 years ago

Trying to add-song or add-album results in the following exception (this is on Arch):

com.github.codyfish.ulauncher-mpd | 2020-04-12 19:53:26,379 | DEBUG | mpd.base: _write_command() | Calling MPD play('96',) Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/ulauncher/api/client/Client.py", line 54, in on_message self.extension.trigger_event(event) File "/usr/lib/python3.8/site-packages/ulauncher/api/client/Extension.py", line 52, in trigger_event action = listener.on_event(event, self) File "~/.local/share/ulauncher/extensions/com.github.codyfish.ulauncher-mpd/main.py", line 47, in on_event self.__mpd_controller.execute(command) File "~/.local/share/ulauncher/extensions/com.github.codyfish.ulauncher-mpd/MpdController.py", line 97, in execute if not self.ensure_connection(): File "/usr/lib/python3.8/site-packages/mpd/base.py", line 381, in mpd_command return wrapper(self, name, args, callback) File "/usr/lib/python3.8/site-packages/mpd/base.py", line 473, in _execute return retval() File "/usr/lib/python3.8/site-packages/mpd/base.py", line 368, in command_callback res = function(self, self._read_lines()) File "/usr/lib/python3.8/site-packages/mpd/base.py", line 311, in _parse_nothing for line in lines: File "/usr/lib/python3.8/site-packages/mpd/base.py", line 538, in _read_lines line = self._read_line() File "/usr/lib/python3.8/site-packages/mpd/base.py", line 527, in _read_line raise CommandError(error) mpd.base.CommandError: [2@0] {play} Bad song index

I always seem to run into this call: Calling MPD play('96',)

codyfish commented 4 years ago

I am moving this to a new issue as it doesn't seen to have anything todo with the perl regexes. I am on arch as well so the version shouldn't be the problem. Do song-insert and album-insert work?

ragusa87 commented 4 years ago

Hello @codyfish , any updates on this ? Do you need anything from me ?

codyfish commented 4 years ago

So, as I've mentioned above, the issue seems to be that there are different mpd (and probably mpc) versions out there. Those who are compiled with perl support should work fine with this extension (note that bretello's issue could be solved, he is on the same distro as I am). I haven't found a nice alternative to using regex for fuzzy finding, and that's a feature I personally use a lot. At the moment, I sadly do not have enough time to install a different mpd version on a vm, for example, and fix this issue. Maybe I'll have enough during summer.

What you could do:

codyfish commented 4 years ago

@ragusa87, a few days ago, there has been an update from python-mpd2 to version 1.1.0. It broke some of my code (which should be fixed now). I highly doubt that this changes anything for you though.

ragusa87 commented 4 years ago

@codyfish Hello, I switched from mpd to mopidy (v3.0.2) with Mopidy-MPD plugin (v3.0.0). The protocol implementation is totally custom (and oldish). It may be a way to start without having to install mpd on a VM.

Sorry but I have no time neither to fix the issue. It's not a big deal for me anyway, the rest is working quite smoothly.

Regarding python-mpd2, the update is still not available to me. Let's wait and see.

pip3 install -U --user python-mpd2  
> Requirement already up-to-date: python-mpd2 in ./.local/lib/python3.8/site-packages (1.0.0)

Have a nice day,

codyfish commented 4 years ago

Surprisingly, I do actually have some time at the moment. Does mpc list artist work for you? If so, I could implement my own regex feature for that list.