Add some integration tests bfe247cf parent 11f18552

authored by Polochon_street

1
[![crate](https://img.shields.io/crates/v/blissify.svg)](https://crates.io/crates/blissify)
2
[![build](https://github.com/Polochon-street/blissify-rs/workflows/Rust/badge.svg)](https://github.com/Polochon-street/blissify-rs/actions)
3
4
# Blissify - analyze an MPD library and make smart playlists
5
6
Blissify is a program used to make playlists of songs that sound alike
7
from your [MPD](https://www.musicpd.org/) track library, à la Spotify radio.
8
9
Under the hood, it is an [MPD](https://www.musicpd.org/) plugin
10
for [bliss](https://crates.io/crates/bliss-audio).
11
12
Blissify needs first to analyze your music library, i.e. compute and store
13
a series of features from your songs, extracting the tempo, timbre,
14
loudness, etc.
15
16
After that, it is ready to make playlists: play a song to start from, run
17
`blissify playlist 30`, and voilà! You have a playlist of 30 songs that
18
sound like your first track.
19
20
Note: you *need* to have MPD installed to use blissify. Otherwise, you
21
probably want to implement bliss-rs support for the audio player you use.
22
23
# Installation / Usage
24
25
You'll need clang, pkg-config and ffmpeg libraries (including development
26
headers) to install it, as well as a
27
[working Rust installation](https://www.rust-lang.org/tools/install)
28
29
On Debian-based systems:
30
31
$ sudo apt install -y build-essential pkg-config libavutil-dev libavformat-dev \
32
libavfilter-dev libavdevice-dev libclang-dev libsqlite3-dev
33
34
On Archlinux:
35
36
$ sudo pacman -S base-devel clang ffmpeg
37
38
Finally, use `cargo install blissify` to install it.
39
40
Note: if you are using a raspberry pi and its corresponding ffmpeg
41
(i.e. `ffmpeg -version|grep rpi` gives back something), use
42
`cargo install --features=rpi blissify` instead.
43
44
45
All the commands below read the `MPD_HOST` and `MPD_PORT` environment
46
variables and try to reach MPD using that. You might want to change
47
it if MPD is listening to somewhere else than `127.0.0.1:6600` (the default).
48
It should be fully compatible with [the MPD documentation](https://mpd.readthedocs.io/en/latest/client.html#connecting-to-mpd).
49
50
## Analyze a library
51
52
To initialize and analyze your MPD library, use
53
```
54
$ blissify init /path/to/mpd/root
55
```
56
57
It will create a configuration file `config.json` and a database file
58
`songs.db` in `~/.local/share/bliss-rs`. If you want to specify a different
59
path for the configuration file and the database file, running
60
```
61
$ blissify -c /path/to/configuration.json init -d /path/to/database.db /path/to/mpd/root
62
```
63
should do the trick. All the subsequent blissify commands should start
64
with `blissify -c /path/to/configuration.json` in order to work.
65
66
Note that it may take several minutes (up to some hours, on very large
67
libraries with more than for instance 20k songs) to complete.
68
69
You can further update your library by running
70
```
71
$ blissify update
72
```
73
74
If something goes wrong and the database enters an
75
unstable state, you can use
76
```
77
$ blissify rescan
78
```
79
to remove the existing database and rescan all files.
80
81
If you want to see if the analysis has been successful, or simply want to see
82
the current files in the database, you can use
83
```
84
$ blissify list-db
85
```
86
87
## Make a playlist
88
89
### Simple version
90
91
```
92
$ blissify playlist 100
93
```
94
95
This will add 100 songs similar to the song that is currently
96
playing on MPD, starting with the closest possible. This will also remove
97
all the others songs previously in the queue, leaving only the smart playlist.
98
99
If you wish to queue the songs after the current playing song but keep the
100
current queue, you can use the `--keep-current-queue` flag, like so:
101
102
```
103
$ blissify playlist 100 --keep-current-queue
104
```
105
106
### Changing the distance metric
107
108
To make a playlist with a distance metric different than the default one
109
(euclidean distance), which will yield different playlists, run:
110
111
```
112
$ blissify playlist --distance <distance_name> 30
113
```
114
115
`distance_name` can currently be `euclidean` or `cosine`. Don't hesitate to
116
experiment with this parameter if the generated playlists are not to your
117
linking!
118
119
### Make a "seeded" playlist
120
121
Instead of making a playlist with songs that are only similar to the first song,
122
from the most similar to the least similar (the default), you can make a
123
playlist that queues the closest song to the first song, then the closest song
124
the second song, etc, effectively making "path" through the songs.
125
126
To try it out (it can take a bit more time to build the playlist):
127
128
```
129
$ blissify playlist --seed-song 30
130
```
131
132
### Make an album playlist
133
134
You can also make a playlist of albums that sound like the current album
135
you're listening to (more specifically, the album of the current song you're
136
playing, regardless of whether you queued the full album or not).
137
138
To try it out:
139
140
```
141
$ blissify playlist --album-playlist 30
142
```
143
144
If you wish to queue the albums after the current playing album, but keep the
145
current queue, you can use the `--keep-current-queue` flag, like so:
146
147
```
148
$ blissify playlist --album-playlist 100 --keep-current-queue
149
```
150
151
### Make an interactive playlist
152
153
Interactive playlists start from a song, and let you choose which song should
154
be played next among the 3 closest songs (the number of songs displayed
155
can be set manually):
156
157
```
158
$ blissify interactive-playlist --number-choices 5
159
```
160
161
By default, it crops the current playlist to just keep the currently played
162
song. If you want to just start from the last song and continue from there, use
163
`--continue`:
164
165
```
166
$ blissify interactive-playlist --number-choices 5 --continue
167
```
168
169
### Dry run mode
170
171
If you want to see which playlist blissify would make without changing the
172
queue at all, or you wish to plug blissify's output somewhere else, you
173
can use the `--dry-run` option, like so:
174
175
```
176
$ blissify playlist 100 --dry-run
177
```
178
179
# Metric learning
180
181
If you feel like making your smart™️ playlists even smarter®️ , take a look
182
at the [metric-learning](https://github.com/Polochon-street/bliss-metric-learning)
183
repo. It gives you the possibility of evaluating the proximity of your own
184
songs, and tailor playlists to your own taste.
185
186
Once you ran the tool in the [metric-learning](https://github.com/Polochon-street/bliss-metric-learning)
187
repo, you can use the mahalanobis distance to make playlists from the learned
188
metric:
189
190
```
191
$ blissify playlist 100 --distance mahalanobis
192
```
193
194
Note that it is all very much alpha development, so if you have any feedback,
195
feel free to submit an issue.
196
197
# Details
198
199
If you are interested about what is happening under the hood, or want to make
200
a similar plug-in for other audio players, see
201
[bliss' doc](https://docs.rs/crate/bliss-audio/).
202
203
# Troubleshooting
204
205
If you are compiling blissify-rs for non-linux OSes, you might run into an
206
error telling you to use the bindgen feature:
207
208
```
209
error: failed to run custom build command for `bliss-audio-aubio-sys v0.2.2`
210
211
Caused by:
212
process didn't exit successfully: `path/release/build/bliss-audio-aubio-sys-fb4d0ec74b3698ed/build-script-build` (exit status: 101)
213
--- stderr
214
thread 'main' panicked at .cargo/registry/src/index.crates.io-6f17d22bba15001f/bliss-audio-aubio-sys-0.2.2/build.rs:34:13:
215
No prebuilt bindings. Try use `bindgen` feature.
216
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
217
warning: build failed, waiting for other jobs to finish...
218
error: failed to compile `blissify v0.4.1`, intermediate artifacts can be found at `/var/folders/pb/g43q604n6v71kwp_89ccy6840000gn/T/cargo-installoyKiUv`.
219
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
220
```
221
222
To fix this and build blissify-rs successfully, use `cargo install blissify --features=default,bliss-audio/update-aubio-bindings`.
223