beetbox / beetbox/beets

List distinct values for an attribute

Open
#824 5 comments 0 reactions 1 assignee Claimed by @PierreRust View on GitHub
feature
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

For the upcoming web API, I'd like to be able to get the list distinct values for an attribute, this would be extremely useful to get for example the list of all artists (instead of creating a new artist object) , or the list of existing genres, composers, etc.

The most important part is the python API, which will be used by the web API plugin, but a command line interface would certainly be nice too.

Here is my ideas for these API :

**Python API**

Two new methods in library :

```
def item field_values( field, query) :
"""Get a list of the existing values for this field in all items matching the query.
"""

def album field_values( field, query) :
"""Get a list of the existing values for this field in all albums matching the query.
"""
```

**Command line API**

```
beet list_field [-a]
```

Queries the database for field values.
This prints out the list or existing values for the field named FIELD with the number of items that currently have this value.
You can use the -a switch to list album-level fields instead of items-level field.

for example :

```
beet list_field -a 'genre' year:2014

rock : 15
folk : 5
jazz : 8
...
```

I still have some doubts about the CLI API, particularly on the distinction between the field name and the query.

What do you think of this ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.