sampsyo/beets — pull request #445 by pscn (2013-11-04 13:14:11+00:00)
Title: Allow plugins to add field types information for flexattrs

As discussed in #424 here's a proposal based on @sampsyo suggestion. It allows plugins to define field *types*.

In the plugin ```__init__``` method you can now define the field types like so:

```python
self.field_types['rating'] = float
self.field_types['play_count'] = int
self.field_types['skip_count'] = int
```

```int``` and ```float``` will use the ```NumericQuery. Every other value will fallback to the ```SubstringQuery```. A rudimentary conflict detection is also in place which will output something like this::

```bash
conflicting field type mapping detected. "liveness" declared by "echonest" as "" and by "mpdstats" as ""
```

A few examples how this looks like in action:

```bash
# beet ls -f '$liveness: $artist - $title' liveness:0.791..0.792
0.791427063558378: Be Your Own Pet - Food Fight!
0.791255853844374: Beastie Boys - Heart Attack Man
0.791988194947472: Cliffy and Jerry - Looking for My Baby
0.791699597106726: The Doors - When the Music's Over
[ ... ]
# beet ls -f '$play_count: $artist - $title' play_count:1..2
1: Curtis Lee - Pretty Little Angel Eyes
1: The Marvelettes - Beechwood 4-5789
[ ... ]
```

Would this be doable?