Skip to content

Commit

Permalink
Prepare for crates.io release
Browse files Browse the repository at this point in the history
  • Loading branch information
Polochon-street committed May 18, 2021
1 parent 63dc494 commit 7d024eb
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 108 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-04-01
override: false
- name: Packages
run: sudo apt-get install build-essential yasm
- name: Build
Expand Down
48 changes: 24 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blissify-rs"
version = "0.1.0"
name = "blissify"
version = "0.1.3"
authors = ["Polochon-street <[email protected]>"]
edition = "2018"
license = "GPL-3.0-only"
Expand All @@ -11,7 +11,7 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bliss-rs = "0.1.1"
bliss-audio = "0.1.3"
mpd = "0.0.12"
rusqlite = "0.25.0"
dirs = "3.0.1"
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
[![crate](https://img.shields.io/crates/v/blissify.svg)](https://crates.io/crates/blissify)
[![build](https://github.com/Polochon-street/blissify-rs/workflows/Rust/badge.svg)](https://github.com/Polochon-street/blissify-rs/actions)

Blissify - analyze an MPD library and make smart playlists
==========================================================

Blissify is an MPD plugin for [bliss](https://crates.io/crates/bliss-rs).
Blissify is an [MPD](https://www.musicpd.org/) plugin
for [bliss](https://crates.io/crates/bliss-audio).

You can use it to make playlists of songs that sound alike from an MPD
library.

Note: the `blissify-rs` crate is outdated. Use this crate (`blissify`) instead.

Usage
=====

Use `cargo install blissify` to install it.

Then analyze your MPD library by using `blissify --update /path/to/mpd/root`
Analyze a library
-----------------

To analyze your MPD library, use
```
$ blissify --update /path/to/mpd/root
```
(or `blissify --rescan /path/to/mpd/root`).

Then, when a song is playing, run `blissify --playlist 100` to make a playlist
of 100 songs similar to the current song.
Make a playlist
---------------

```
$ blissify --playlist 100
```

This will add 100 songs similar to the song that is currently
playing on MPD, starting with the closest possible.
146 changes: 73 additions & 73 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
//! Playlists can then subsequently be made from the current song using
//! --playlist.
use anyhow::{bail, Context, Result};
use bliss_rs::library::Library;
use bliss_rs::{BlissError, Song};
use bliss_audio::Library;
use bliss_audio::{BlissError, Song};
use clap::{App, Arg, ArgGroup};
#[cfg(not(test))]
use dirs::data_local_dir;
use env_logger;
use log::info;
#[cfg(not(test))]
use log::warn;
Expand Down Expand Up @@ -88,11 +87,13 @@ impl MPDLibrary {
)?;
let results = stmt.query_map(params![&path.to_str().unwrap()], MPDLibrary::row_closure)?;

let mut song = Song::default();
song.path = path
.to_str()
.with_context(|| "While getting current song path")?
.to_owned();
let mut song = Song {
path: path
.to_str()
.with_context(|| "While getting current song path")?
.to_owned(),
..Default::default()
};
let mut analysis = vec![];
for result in results {
analysis.push(result?.1);
Expand Down Expand Up @@ -230,14 +231,14 @@ impl Library for MPDLibrary {
let mut songs_hashmap = HashMap::new();
for result in results {
let result = result.map_err(|e| BlissError::ProviderError(e.to_string()))?;
let song_entry = songs_hashmap.entry(result.0).or_insert(vec![]);
let song_entry = songs_hashmap.entry(result.0).or_insert_with(Vec::new);
song_entry.push(result.1);
}
let songs: Vec<Song> = songs_hashmap
.into_iter()
.map(|(path, analysis)| Song {
analysis,
path,
analysis,
..Default::default()
})
.collect();
Expand Down Expand Up @@ -445,69 +446,68 @@ mod test {
}

#[test]
// fn test_full_rescan() {
// let mut library = MPDLibrary::new(String::from("./data/")).unwrap();
// let sqlite_conn = library.sqlite_conn.lock().unwrap();
// sqlite_conn
// .execute(
// "
// insert into song (id, path, analyzed) values
// (1,'./data/s16_mono_22_5kHz.flac', true)
// ",
// [],
// )
// .unwrap();
//
// sqlite_conn
// .execute(
// "
// insert into feature (song_id, feature, feature_index) values
// (1, 0., 1),
// (1, 0., 2),
// (1, 0., 3)
// ",
// [],
// )
// .unwrap();
// drop(sqlite_conn);
//
// library.full_rescan().unwrap();
//
// let sqlite_conn = library.sqlite_conn.lock().unwrap();
// let mut stmt = sqlite_conn
// .prepare("select path, analyzed from song order by path")
// .unwrap();
// let expected_songs = stmt
// .query_map([], |row| Ok((row.get(0).unwrap(), row.get(1).unwrap())))
// .unwrap()
// .map(|x| {
// let x = x.unwrap();
// (x.0, x.1)
// })
// .collect::<Vec<(String, bool)>>();
//
// assert_eq!(
// expected_songs,
// vec![
// (String::from("foo"), false),
// (String::from("s16_mono_22_5kHz.flac"), true),
// (String::from("s16_stereo_22_5kHz.flac"), true),
// ],
// );
//
// let mut stmt = sqlite_conn
// .prepare("select count(*) from feature group by song_id")
// .unwrap();
// let expected_feature_count = stmt
// .query_map([], |row| row.get(0))
// .unwrap()
// .map(|x| x.unwrap())
// .collect::<Vec<u32>>();
// for feature_count in expected_feature_count {
// assert!(feature_count > 1);
// }
// }

// fn test_full_rescan() {
// let mut library = MPDLibrary::new(String::from("./data/")).unwrap();
// let sqlite_conn = library.sqlite_conn.lock().unwrap();
// sqlite_conn
// .execute(
// "
// insert into song (id, path, analyzed) values
// (1,'./data/s16_mono_22_5kHz.flac', true)
// ",
// [],
// )
// .unwrap();
//
// sqlite_conn
// .execute(
// "
// insert into feature (song_id, feature, feature_index) values
// (1, 0., 1),
// (1, 0., 2),
// (1, 0., 3)
// ",
// [],
// )
// .unwrap();
// drop(sqlite_conn);
//
// library.full_rescan().unwrap();
//
// let sqlite_conn = library.sqlite_conn.lock().unwrap();
// let mut stmt = sqlite_conn
// .prepare("select path, analyzed from song order by path")
// .unwrap();
// let expected_songs = stmt
// .query_map([], |row| Ok((row.get(0).unwrap(), row.get(1).unwrap())))
// .unwrap()
// .map(|x| {
// let x = x.unwrap();
// (x.0, x.1)
// })
// .collect::<Vec<(String, bool)>>();
//
// assert_eq!(
// expected_songs,
// vec![
// (String::from("foo"), false),
// (String::from("s16_mono_22_5kHz.flac"), true),
// (String::from("s16_stereo_22_5kHz.flac"), true),
// ],
// );
//
// let mut stmt = sqlite_conn
// .prepare("select count(*) from feature group by song_id")
// .unwrap();
// let expected_feature_count = stmt
// .query_map([], |row| row.get(0))
// .unwrap()
// .map(|x| x.unwrap())
// .collect::<Vec<u32>>();
// for feature_count in expected_feature_count {
// assert!(feature_count > 1);
// }
// }
#[test]
fn test_playlist_no_song() {
let library = MPDLibrary::new(String::from("")).unwrap();
Expand Down

0 comments on commit 7d024eb

Please sign in to comment.