Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpdstats: Error when querying play_count with a sort order #5512

Open
Co3co opened this issue Nov 22, 2024 · 1 comment
Open

mpdstats: Error when querying play_count with a sort order #5512

Co3co opened this issue Nov 22, 2024 · 1 comment
Labels
good first issue https://github.com/beetbox/beets/pull/5479

Comments

@Co3co
Copy link

Co3co commented Nov 22, 2024

Error when sorting certain mpdstats queries

Running this command in verbose (-vv) mode:

$ beet -vv list play_count+

Led to this problem:

user configuration: ~/.config/beets/config.yaml
data directory: ~/.config/beets
plugin paths: 
Sending event: pluginload
library database: ~/Music/musiclibrary.db
library directory: ~/Music
Sending event: library_opened
Parsed query: AndQuery([TrueQuery()])
Parsed sort: SlowFieldSort('play_count', ascending=True)
Traceback (most recent call last):
  File "/usr/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.12/site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "/usr/lib/python3.12/site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.12/site-packages/beets/ui/commands.py", line 1599, in list_func
    list_items(lib, decargs(args), opts.album)
  File "/usr/lib/python3.12/site-packages/beets/ui/commands.py", line 1594, in list_items
    for item in lib.items(query):
                ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/beets/dbcore/db.py", line 823, in __iter__
    objects = self.sort.sort(list(self._get_objects()))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/beets/dbcore/query.py", line 984, in sort
    return sorted(objs, key=key, reverse=not self.ascending)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'int' and 'str'

Setup

  • OS: Artix Linux
  • Python version: 3.12.7
  • beets version: 1.6.1
  • Turning off plugins made problem go away (yes/no): yes

My configuration (output of beet config) is:

directory: ~/Music
# --------------- Main ---------------

library: ~/Music/musiclibrary.db

# --------------- Plugins ---------------

plugins: mpdstats

import:
    copy: no
mpd:
    music_directory: ~/Music
    strip_path: ''
    rating: yes
    rating_mix: 0.75
    host: localhost
    port: 6600
    password: REDACTED

It also happens with list rating+ and list skip_count+. It happens with both ascending (play_count+) and descending (play_count-) sorting.

@snejus
Copy link
Member

snejus commented Nov 22, 2024

This is happening because values for these fields are expected to be numeric, however beets fails handling empty values which appear as empty strings. This needs fixing for sure.

Meanwhile, try filtering for non-empty values in your query:

-$ beet -vv list play_count+
+$ beet -vv list play_count+ play_count::.

play_count::. picks up everything that has at least one character

@snejus snejus added the good first issue https://github.com/beetbox/beets/pull/5479 label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue https://github.com/beetbox/beets/pull/5479
Projects
None yet
Development

No branches or pull requests

2 participants