| 1 |
MPDStats Plugin |
| 2 |
=============== |
| 3 |
|
| 4 |
``mpdstats`` is a plugin for beets that collects statistics about your listening |
| 5 |
habits from MPD_. It collects the following information about tracks: |
| 6 |
|
| 7 |
- ``play_count``: The number of times you *fully* listened to this track. |
| 8 |
- ``skip_count``: The number of times you *skipped* this track. |
| 9 |
- ``last_played``: UNIX timestamp when you last played this track. |
| 10 |
- ``rating``: A rating based on ``play_count`` and ``skip_count``. |
| 11 |
|
| 12 |
To gather these statistics it runs as an MPD client and watches the current |
| 13 |
state of MPD. This means that ``mpdstats`` needs to be running continuously for |
| 14 |
it to work. |
| 15 |
|
| 16 |
.. _mpd: https://www.musicpd.org/ |
| 17 |
|
| 18 |
Installing Dependencies |
| 19 |
----------------------- |
| 20 |
|
| 21 |
This plugin requires the python-mpd2 library in order to talk to the MPD server. |
| 22 |
|
| 23 |
To use the ``mpdstats`` plugin, first enable it in your configuration (see |
| 24 |
:ref:`using-plugins`). Then, install ``beets`` with ``mpdstats`` extra |
| 25 |
|
| 26 |
pip install "beets[mpdstats]" |
| 27 |
|
| 28 |
Usage |
| 29 |
----- |
| 30 |
|
| 31 |
Use the ``mpdstats`` command to fire it up: |
| 32 |
|
| 33 |
:: |
| 34 |
|
| 35 |
$ beet mpdstats |
| 36 |
|
| 37 |
Configuration |
| 38 |
------------- |
| 39 |
|
| 40 |
To configure the plugin, make an ``mpd:`` section in your configuration file. |
| 41 |
The available options are: |
| 42 |
|
| 43 |
- **host**: The MPD server hostname. Default: The ``$MPD_HOST`` environment |
| 44 |
variable if set, falling back to ``localhost`` otherwise. |
| 45 |
- **port**: The MPD server port. Default: The ``$MPD_PORT`` environment variable |
| 46 |
if set, falling back to 6600 otherwise. |
| 47 |
- **password**: The MPD server password. Default: None. |
| 48 |
- **music_directory**: If your MPD library is at a different location from the |
| 49 |
beets library (e.g., because one is mounted on a NFS share), specify the path |
| 50 |
here. |
| 51 |
- **strip_path**: If your MPD library contains local path, specify the part to |
| 52 |
remove here. Combining this with **music_directory** you can mangle MPD path |
| 53 |
to match the beets library one. Default: The beets library directory. |
| 54 |
- **rating**: Enable rating updates. Default: ``yes``. |
| 55 |
- **rating_mix**: Tune the way rating is calculated (see below). Default: 0.75. |
| 56 |
- **played_ratio_threshold**: If a song was played for less than this percentage |
| 57 |
of its duration it will be considered a skip. Default: 0.85 |
| 58 |
|
| 59 |
A Word on Ratings |
| 60 |
----------------- |
| 61 |
|
| 62 |
Ratings are calculated based on the *play_count*, *skip_count* and the last |
| 63 |
*action* (play or skip). It consists in one part of a *stable_rating* and in |
| 64 |
another part on a *rolling_rating*. The *stable_rating* is calculated like this: |
| 65 |
|
| 66 |
:: |
| 67 |
|
| 68 |
stable_rating = (play_count + 1.0) / (play_count + skip_count + 2.0) |
| 69 |
|
| 70 |
So if the *play_count* equals the *skip_count*, the *stable_rating* is always |
| 71 |
0.5. More *play_counts* adjust the rating up to 1.0. More *skip_counts* adjust |
| 72 |
it down to 0.0. One of the disadvantages of this rating system, is that it |
| 73 |
doesn't really cover *recent developments*. e.g. a song that you loved last year |
| 74 |
and played over 50 times will keep a high rating even if you skipped it the last |
| 75 |
10 times. That's were the *rolling_rating* comes in. |
| 76 |
|
| 77 |
If a song has been fully played, the *rolling_rating* is calculated like this: |
| 78 |
|
| 79 |
:: |
| 80 |
|
| 81 |
rolling_rating = old_rating + (1.0 - old_rating) / 2.0 |
| 82 |
|
| 83 |
If a song has been skipped, like this: |
| 84 |
|
| 85 |
:: |
| 86 |
|
| 87 |
rolling_rating = old_rating - old_rating / 2.0 |
| 88 |
|
| 89 |
So *rolling_rating* adapts pretty fast to *recent developments*. But it's too |
| 90 |
fast. Taking the example from above, your old favorite with 50 plays will get a |
| 91 |
negative rating (<0.5) the first time you skip it. Also not good. |
| 92 |
|
| 93 |
To take the best of both worlds, we mix the ratings together with the |
| 94 |
``rating_mix`` factor. A ``rating_mix`` of 0.0 means all *rolling* and 1.0 means |
| 95 |
all *stable*. We found 0.75 to be a good compromise, but fell free to play with |
| 96 |
that. |
| 97 |
|
| 98 |
Warning |
| 99 |
------- |
| 100 |
|
| 101 |
This has only been tested with MPD versions >= 0.16. It may not work on older |
| 102 |
versions. If that is the case, please report an issue_. |
| 103 |
|
| 104 |
.. _issue: https://github.com/beetbox/beets/issues |