sampsyo/beets — pull request #424 by pscn (2013-10-17 20:57:19+00:00)
Title: New plugin to fetch extended information from the EchoNest (call for feedback)

This is an experimental plugin to fetch extended information from the EchoNest and store them in flexible attributes. It's basically an extension of the ```echonest_tempo``` plugin and can also fetch ```tempo```, but that's not the fun part. It also fetches ```energy```, ```liveness```, ```speechiness```, ```acousticness```, ```danceability```, ```valence``` and tries to guess the ```mood``` based on a *Valence-Arousal space*. For details on the ```mood``` guessing see [here](http://developer.echonest.com/forums/thread/1297) and [here](http://mat.ucsb.edu/~ivana/200a/background.htm). The ```mood``` stuff is funny, but not more (at the moment). Probably the algorithm I use is buggy and / or I didn't understand what I was doing at all (very likely).

Everything (except for ```tempo```) is returned in values ranging from 0.0 to 1.0. That's maybe interesting for calculations, but not for queries within beets. So I thought about mapping those values into something *human readable*. The plugin provides config options to define a mapping for every attribute (except ```tempo``` which is not mapped and ```mood``` which is hard coded at the moment).

The default mapping (only used by ```energy``` and ```valence``` at the moment) is *very low*, *low*, *neutral*, *high* and *very high*. Providing for queries like ```beet ls energy:'high'``` and getting ```high``` and ```very high``` energy tracks.

I was playing with the mappings for some time and these are the current defaults:
```danceability``` uses *bed*, *couch*, *unsure*, *party* and *disco*.
```liveness``` uses *studio*, *probably studio*, *probably live* and *live*.
```speechiness``` uses *singing*,*unsure* and*talking*.
```acousticness``` uses *artificial*, *probably artifical*, *probably natural* and *natural*.

A config example:
```yaml
echoplus:
mapping: 1,2,3,4,5
danceability_mapping: potato, tomato, bananas
upload: true
```

Yes, it can upload files to the EchoNest, if the format is supported (FLAC is not). It tries to upload, when upload is enabled and no good match (distance between the local track length and the EchoNest track length is > 1.0 second).

It requires a recent versioon of pyechonest, so ```pip install --upgrad pyechonest``` is required.

At the moment it stores the un-mapped values in extra flexible attributes, so you can use the ```-r``` switch to *reapply* already fetched values. Suggested for playing with mappings.

Ok, a little example output:

```bash
beet -v echoplus -r artist:'black sabbath' title:'paranoid'
[ ... ]
echoplus: Black Sabbath - Paranoid [172.8] force:False reapply:True
echoplus: format FLAC not supported for upload
echoplus: (re-)applying data
echoplus: mapped energy: 0.62 > high
echoplus: mapped liveness: 0.10 > studio
echoplus: mapped speechiness: 0.07 > singing
echoplus: mapped acousticness: 0.03 > artificial
echoplus: mapped danceability: 0.37 > couch
echoplus: mapped valence: 0.38 > low
echoplus: mapped mood: 0.38x0.62 = slightly nervous

beet ls -f '$liveness' artist:'black sabbath' title:'paranoid'
studio

beet ls liveness:studio
Black Sabbath - Paranoid - Paranoid
```

That's it. It's probably buggy, requires more thinking, cleaning up and most of all feedback. Is this something of interest? Does this make sense at all?

Cheers,
Peter